From 13ae3a91292dc2d2727d34dbc18c8e12967d9cdd Mon Sep 17 00:00:00 2001 From: fireice-uk Date: Tue, 14 Mar 2017 21:22:04 +0000 Subject: [PATCH] stak updates - v 1.3.1 --- cli-miner.cpp | 7 +++++++ crypto/soft_aes.c | 7 +++++++ httpd.cpp | 18 +++++++++++++----- jconf.cpp | 9 +++++++++ jpsock.cpp | 6 +++++- socket.cpp | 4 ++++ webdesign.cpp | 34 ++++++++++++++++++++-------------- 7 files changed, 65 insertions(+), 20 deletions(-) diff --git a/cli-miner.cpp b/cli-miner.cpp index 184d5aa..365ea27 100644 --- a/cli-miner.cpp +++ b/cli-miner.cpp @@ -32,7 +32,10 @@ #include #include +#ifndef CONF_NO_TLS #include +#include +#endif //Do a press any key for the windows folk. *insert any key joke here* #ifdef _WIN32 @@ -53,10 +56,14 @@ void do_benchmark(); int main(int argc, char *argv[]) { +#ifndef CONF_NO_TLS SSL_library_init(); SSL_load_error_strings(); ERR_load_BIO_strings(); + ERR_load_crypto_strings(); + SSL_load_error_strings(); OpenSSL_add_all_digests(); +#endif const char* sFilename = "config.txt"; bool benchmark_mode = false; diff --git a/crypto/soft_aes.c b/crypto/soft_aes.c index b8309cf..aba7c20 100644 --- a/crypto/soft_aes.c +++ b/crypto/soft_aes.c @@ -195,6 +195,13 @@ static inline void sub_word(uint8_t* key) key[3] = Sbox[key[3]]; } +#ifdef __clang__ +uint32_t _rotr(uint32_t value, uint32_t amount) +{ + return (value >> amount) | (value << ((32 - amount) & 31)); +} +#endif + __m128i soft_aeskeygenassist(__m128i key, uint8_t rcon) { uint32_t X1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(key, 0x55)); diff --git a/httpd.cpp b/httpd.cpp index 84612dd..927bc39 100644 --- a/httpd.cpp +++ b/httpd.cpp @@ -101,12 +101,20 @@ int httpd::req_handler(void * cls, } else { - char buffer[1024]; - snprintf(buffer, sizeof(buffer), "Error" - "
Unkown url %s - please use /h, /r or /c as url
", url); + //Do a 302 redirect to /h + char loc_path[256]; + const char* host_val = MHD_lookup_connection_value(connection, MHD_HEADER_KIND, "Host"); - rsp = MHD_create_response_from_buffer(strlen(buffer), - (void*)buffer, MHD_RESPMEM_MUST_COPY); + if(host_val != nullptr) + snprintf(loc_path, sizeof(loc_path), "http://%s/h", host_val); + else + snprintf(loc_path, sizeof(loc_path), "/h"); + + rsp = MHD_create_response_from_buffer(0, nullptr, MHD_RESPMEM_PERSISTENT); + int ret = MHD_queue_response(connection, MHD_HTTP_TEMPORARY_REDIRECT, rsp); + MHD_add_response_header(rsp, "Location", loc_path); + MHD_destroy_response(rsp); + return ret; } int ret = MHD_queue_response(connection, MHD_HTTP_OK, rsp); diff --git a/jconf.cpp b/jconf.cpp index 5d22f80..7b23062 100644 --- a/jconf.cpp +++ b/jconf.cpp @@ -28,6 +28,15 @@ #include #include +#ifdef CONF_NO_TLS + if(prv->configValues[bTlsMode]->GetBool()) + { + printer::inst()->print_msg(L0, + "Invalid config file. TLS enabled while the application has been compiled without TLS support."); + return false; + } +#endif // CONF_NO_TLS + #ifdef _WIN32 #define strcasecmp _stricmp #include diff --git a/jpsock.cpp b/jpsock.cpp index b072c21..70241f9 100644 --- a/jpsock.cpp +++ b/jpsock.cpp @@ -33,7 +33,7 @@ #include "socks.h" #include "socket.h" -#define AGENTID_STR "xmr-stak-amd/1.0" +#define AGENTID_STR "xmr-stak-amd/1.3.1" using namespace rapidjson; @@ -103,10 +103,14 @@ jpsock::jpsock(size_t id, bool tls) : pool_id(id) prv = new opaque_private(bJsonCallMem, bJsonRecvMem, bJsonParseMem); +#ifndef CONF_NO_TLS if(tls) sck = new tls_socket(this); else sck = new plain_socket(this); +#else + sck = new plain_socket(this); +#endif oRecvThd = nullptr; bRunning = false; diff --git a/socket.cpp b/socket.cpp index b472feb..565eb76 100644 --- a/socket.cpp +++ b/socket.cpp @@ -27,6 +27,7 @@ #include "console.h" #include "executor.h" +#ifndef CONF_NO_TLS #include #include #include @@ -34,6 +35,7 @@ #ifndef OPENSSL_THREADS #error OpenSSL was compiled without thread support #endif +#endif plain_socket::plain_socket(jpsock* err_callback) : pCallback(err_callback) { @@ -166,6 +168,7 @@ void plain_socket::close(bool free) } } +#ifndef CONF_NO_TLS tls_socket::tls_socket(jpsock* err_callback) : pCallback(err_callback) { } @@ -355,4 +358,5 @@ void tls_socket::close(bool free) bio = nullptr; } } +#endif diff --git a/webdesign.cpp b/webdesign.cpp index 6d96824..75cb232 100644 --- a/webdesign.cpp +++ b/webdesign.cpp @@ -1,15 +1,15 @@ #include -extern const char sHtmlCssEtag [] = "00000005"; +extern const char sHtmlCssEtag [] = "00000006"; extern const char sHtmlCssFile [] = "body {" "font-family: Tahoma, Arial, sans-serif;" "font-size: 80%;" - "background-color: rgb(230, 230, 230);" + "background-color: rgb(240, 240, 240);" "}" "a {" - "color: rgb(43, 51, 62);" + "color: rgb(44, 55, 66);" "}" "a:link {" @@ -17,7 +17,7 @@ extern const char sHtmlCssFile [] = "}" "a:visited {" - "color: rgb(43, 51, 62);" + "color: rgb(44, 55, 66);" "}" "a:hover {" @@ -28,6 +28,11 @@ extern const char sHtmlCssFile [] = "color: rgb(204, 122, 0);" "}" + ".all {" + "max-width:600px;" + "margin: auto;" + "}" + ".header {" "background-color: rgb(30, 30, 30);" "color: white;" @@ -37,9 +42,9 @@ extern const char sHtmlCssFile [] = "}" ".links {" - "padding: 5px;" + "padding: 7px;" "text-align: center;" - "background-color: rgb(213, 213, 213);" + "background-color: rgb(215, 215, 215);" "box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.2), 0px 1px 1px 0px rgba(0, 0, 0, 0.14), 0px 2px 1px -1px rgba(0, 0, 0, 0.12);" "}" @@ -67,7 +72,7 @@ extern const char sHtmlCssFile [] = "}" "h4 {" - "background-color: rgb(0, 129, 124);" + "background-color: rgb(0, 130, 130);" "color: white;" "padding: 10px;" "margin: 10px 0px;" @@ -80,7 +85,7 @@ extern const char sHtmlCssFile [] = ".flex-item {" "width: 33%;" - "margin: 6px;" + "margin: 3px;" "}"; size_t sHtmlCssSize = sizeof(sHtmlCssFile) - 1; @@ -91,7 +96,8 @@ extern const char sHtmlCommonHeader [] = "" "%s" "" - "
XMR-Stak-CPU
" + "
" + "
XMR-Stak-AMD
" "
" ""; + "
"; extern const char sHtmlConnectionBodyHigh [] = "
" @@ -128,14 +134,14 @@ extern const char sHtmlConnectionBodyHigh [] = "Pool ping time%u ms" "" "

Network error log

" - "" + "
" ""; extern const char sHtmlConnectionTableRow [] = ""; extern const char sHtmlConnectionBodyLow [] = - "
DateError
%s%s
"; + ""; extern const char sHtmlResultBodyHigh [] = "
" @@ -154,7 +160,7 @@ extern const char sHtmlResultBodyHigh [] = "9%llu10%llu" "" "

Error details

" - "" + "
" "" ""; @@ -162,5 +168,5 @@ extern const char sHtmlResultTableRow [] = ""; extern const char sHtmlResultBodyLow [] = - "
Error text
CountLast seen
%s
%llu%s
"; + "";