Add version to web and json

This commit is contained in:
Unknown
2017-11-13 19:56:41 +00:00
parent f0875b614c
commit b48ca65c0b
5 changed files with 22 additions and 8 deletions
+1 -1
View File
@@ -299,7 +299,7 @@ int main(int argc, char *argv[])
}
if(opName.compare("-v") == 0 || opName.compare("--version") == 0)
{
std::cout<< "Version: " << get_version_str() << std::endl;
std::cout<< "Version: " << get_version_str_short() << std::endl;
return 0;
}
else if(opName.compare("--noCPU") == 0)
+11 -2
View File
@@ -1,6 +1,6 @@
#include <stdlib.h>
extern const char sHtmlCssEtag [] = "00000006";
extern const char sHtmlCssEtag [] = "00000008";
extern const char sHtmlCssFile [] =
"body {"
"font-family: Tahoma, Arial, sans-serif;"
@@ -38,7 +38,13 @@ extern const char sHtmlCssFile [] =
"color: white;"
"padding: 10px;"
"font-weight: bold;"
"margin: 10px 0px;"
"margin: 0px;"
"margin-bottom: 10px;"
"}"
".version {"
"font-size: 75%;"
"text-align: right;"
"}"
".links {"
@@ -97,6 +103,7 @@ extern const char sHtmlCommonHeader [] =
"<link rel='stylesheet' href='style.css' /><title>%s</title></head>"
"<body>"
"<div class='all'>"
"<div class='version'>%s</div>"
"<div class='header'><span style='color: rgb(255, 160, 0)'>XMR</span>-Stak Monero Miner</div>"
"<div class='flex-container'>"
@@ -181,6 +188,8 @@ extern const char sJsonApiConnectionError[] =
extern const char sJsonApiFormat [] =
"{"
"\"version\":\"%s\","
"\"hashrate\":{"
"\"threads\":[%s],"
"\"total\":%s,"
+7 -5
View File
@@ -33,6 +33,7 @@
#include "xmrstak/jconf.hpp"
#include "xmrstak/misc/console.hpp"
#include "xmrstak/donate-level.hpp"
#include "xmrstak/version.hpp"
#include "xmrstak/http/webdesign.hpp"
#include <thread>
@@ -43,6 +44,7 @@
#include <assert.h>
#include <time.h>
#ifdef _WIN32
#define strncasecmp _strnicmp
#endif // _WIN32
@@ -814,7 +816,7 @@ void executor::http_hashrate_report(std::string& out)
out.reserve(4096);
snprintf(buffer, sizeof(buffer), sHtmlCommonHeader, "Hashrate Report", "Hashrate Report");
snprintf(buffer, sizeof(buffer), sHtmlCommonHeader, "Hashrate Report", ver_html, "Hashrate Report");
out.append(buffer);
snprintf(buffer, sizeof(buffer), sHtmlHashrateBodyHigh, (unsigned int)nthd + 3);
@@ -859,7 +861,7 @@ void executor::http_result_report(std::string& out)
out.reserve(4096);
snprintf(buffer, sizeof(buffer), sHtmlCommonHeader, "Result Report", "Result Report");
snprintf(buffer, sizeof(buffer), sHtmlCommonHeader, "Result Report", ver_html, "Result Report");
out.append(buffer);
size_t iGoodRes = vMineResults[0].count, iTotalRes = iGoodRes;
@@ -905,7 +907,7 @@ void executor::http_connection_report(std::string& out)
out.reserve(4096);
snprintf(buffer, sizeof(buffer), sHtmlCommonHeader, "Connection Report", "Connection Report");
snprintf(buffer, sizeof(buffer), sHtmlCommonHeader, "Connection Report", ver_html, "Connection Report");
out.append(buffer);
jpsock* pool = pick_pool_by_id(current_pool_id);
@@ -1045,11 +1047,11 @@ void executor::http_json_report(std::string& out)
cn_error.append(buffer);
}
size_t bb_size = 1024 + hr_thds.size() + res_error.size() + cn_error.size();
size_t bb_size = 2048 + hr_thds.size() + res_error.size() + cn_error.size();
std::unique_ptr<char[]> bigbuf( new char[ bb_size ] );
int bb_len = snprintf(bigbuf.get(), bb_size, sJsonApiFormat,
hr_thds.c_str(), hr_buffer, a,
get_version_str().c_str(), hr_thds.c_str(), hr_buffer, a,
int_port(iPoolDiff), int_port(iGoodRes), int_port(iTotalRes), fAvgResTime, int_port(iPoolHashes),
int_port(iTopDiff[0]), int_port(iTopDiff[1]), int_port(iTopDiff[2]), int_port(iTopDiff[3]), int_port(iTopDiff[4]),
int_port(iTopDiff[5]), int_port(iTopDiff[6]), int_port(iTopDiff[7]), int_port(iTopDiff[8]), int_port(iTopDiff[9]),
+2
View File
@@ -45,6 +45,8 @@
#define VERSION_LONG XMR_STAK_NAME "/" XMR_STAK_VERSION "/" XMRSTAK_PP_TOSTRING(GIT_COMMIT_HASH) "/" XMRSTAK_PP_TOSTRING(GIT_BRANCH) "/" OS_TYPE "/" XMRSTAK_PP_TOSTRING(BACKEND_TYPE) "/" COIN_TYPE "/"
#define VERSION_SHORT XMR_STAK_NAME " " XMR_STAK_VERSION " " XMRSTAK_PP_TOSTRING(GIT_COMMIT_HASH)
#define VERSION_HTML "v" XMR_STAK_VERSION "-" XMRSTAK_PP_TOSTRING(GIT_COMMIT_HASH)
const char ver_long[] = VERSION_LONG;
const char ver_short[] = VERSION_SHORT;
const char ver_html[] = VERSION_HTML;
+1
View File
@@ -6,6 +6,7 @@
extern const char ver_long[];
extern const char ver_short[];
extern const char ver_html[];
inline std::string get_version_str()
{