summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt11
-rw-r--r--THIRD-PARTY-LICENSES24
-rw-r--r--doc/compile.md10
-rw-r--r--doc/compile_Linux.md4
-rw-r--r--doc/usage.md7
-rw-r--r--xmrstak/backend/amd/minethd.cpp1
-rw-r--r--xmrstak/backend/cpu/minethd.cpp1
-rw-r--r--xmrstak/backend/iBackend.hpp18
-rw-r--r--xmrstak/backend/nvidia/minethd.cpp1
-rw-r--r--xmrstak/config.tpl15
-rw-r--r--xmrstak/http/httpd.cpp26
-rw-r--r--xmrstak/http/webdesign.cpp11
-rw-r--r--xmrstak/http/webdesign.hpp6
-rw-r--r--xmrstak/jconf.cpp14
-rw-r--r--xmrstak/jconf.hpp2
-rw-r--r--xmrstak/misc/executor.cpp102
16 files changed, 206 insertions, 47 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c56284..6e0f282 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,17 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${BUILD_TYPE}")
set(XMR-STAK_CURRENCY "all" CACHE STRING "select miner currency")
set_property(CACHE XMR-STAK_CURRENCY PROPERTY STRINGS "all;monero;aeon")
+if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+ set(XMR-STAK_COMPILE "native" CACHE STRING "select CPU compute architecture")
+ set_property(CACHE XMR-STAK_COMPILE PROPERTY STRINGS "native;generic")
+ if("${XMR-STAK_COMPILE}" STREQUAL "native")
+ set(CMAKE_CXX_FLAGS "-march=native -mtune=native ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_C_FLAGS "-march=native -mtune=native ${CMAKE_C_FLAGS}")
+ elseif(NOT "${XMR-STAK_COMPILE}" STREQUAL "generic")
+ message(FATAL_ERROR "XMR-STAK_COMPILE is set to an unknown value '${XMR-STAK_COMPILE}'")
+ endif()
+endif()
+
if("${XMR-STAK_CURRENCY}" STREQUAL "all")
message(STATUS "Set miner currency to 'monero' and 'aeon'")
elseif("${XMR-STAK_CURRENCY}" STREQUAL "aeon")
diff --git a/THIRD-PARTY-LICENSES b/THIRD-PARTY-LICENSES
new file mode 100644
index 0000000..3e62013
--- /dev/null
+++ b/THIRD-PARTY-LICENSES
@@ -0,0 +1,24 @@
+This application bundles the following third-party software in accordance with the following licenses:
+
+-------------------------------------------------------------------------
+
+Package: Original NVidia mining code
+Authors: tsiv and KlausT
+License: GNU GPLv3
+Notes: Improvements are (c) of Xmr-Stak team
+
+-------------------------------------------------------------------------
+
+Package: Original AMD mining code
+Authors: wolf9466
+License: MIT License
+Notes: Improvements are (c) of Xmr-Stak team and are covered by GNU GPLv3
+
+-------------------------------------------------------------------------
+
+Package: RapidJSON
+Authors: THL A29 Limited, a Tencent company, and Milo Yip
+License: MIT License and BSD License
+
+-------------------------------------------------------------------------
+
diff --git a/doc/compile.md b/doc/compile.md
index 537a736..30cf58c 100644
--- a/doc/compile.md
+++ b/doc/compile.md
@@ -37,6 +37,7 @@ After the configuration you need to compile the miner, follow the guide for your
- you can find the binary and the `config.txt` file after `make install` in `$HOME/xmr-stak-cpu/bin`
- `CMAKE_LINK_STATIC` link libgcc and libstdc++ libraries static (default OFF)
- disable with `cmake .. -DCMAKE_LINK_STATIC=ON`
+ - if you use static compile to run the miner on another system set `-DXMR-STAK_COMPILE=generic` (only available for LINUX, BSD and MacOSX)
- `CMAKE_BUILD_TYPE` set the build type
- valid options: `Release` or `Debug`
- you should always keep `Release` for your productive miners
@@ -44,10 +45,17 @@ After the configuration you need to compile the miner, follow the guide for your
- there is no *http* interface available if option is disabled: `cmake .. -DMICROHTTPD_ENABLE=OFF`
- `OpenSSL_ENABLE` allow to disable/enable the dependency *OpenSSL*
- it is not possible to connect to a *https* secured pool if option is disabled: `cmake .. -DOpenSSL_ENABLE=OFF`
+- `XMR-STAK_CURRENCY` - compile for Monero(XMR) or Aeon(AEON) usage only e.g. `cmake .. -DXMR-STAK_CURRENCY=monero`
+
+### only available for LINUX, BSD and MacOSX
+- `XMR-STAK_COMPILE` select the CPU compute architecture (default: native)
+ - native means the miner binary can be used only on the system where it is compiled but will archive the highest hash rate
+ - use `cmake .. -DXMR-STAK_COMPILE=generic` to run the miner on all CPU's with sse2
+
+### only available for Windows
- `WIN_UAC` will enable or disable the "Run As Administrator" prompt on Windows.
- UAC confirmation is needed to use large pages on Windows 7.
- On Windows 10 it is only needed once to set up the account to use them.
-- `XMR-STAK_CURRENCY` - compile for Monero(XMR) or Aeon(AEON) usage only e.g. `cmake .. -DXMR-STAK_CURRENCY=monero`
## CPU Build Options
diff --git a/doc/compile_Linux.md b/doc/compile_Linux.md
index c9347f5..cf99121 100644
--- a/doc/compile_Linux.md
+++ b/doc/compile_Linux.md
@@ -69,9 +69,9 @@
- g++ version 5.1 or higher is required for full C++11 support.
If you want to compile the binary without installing libraries / compiler or just compile binary for some other distribution, please check the [build_xmr-stak_docker.sh script](scripts/build_xmr-stak_docker/build_xmr-stak_docker.sh).
-### To do a static build for a system without gcc 5.1+
+### To do a generic and static build for a system without gcc 5.1+
```
- cmake -DCMAKE_LINK_STATIC=ON .
+ cmake -DCMAKE_LINK_STATIC=ON -DXMR-STAK_COMPILE=generic .
make install
```
Note - cmake caches variables, so if you want to do a dynamic build later you need to specify '-DCMAKE_LINK_STATIC=OFF'
diff --git a/doc/usage.md b/doc/usage.md
index 30d80fa..ca379ab 100644
--- a/doc/usage.md
+++ b/doc/usage.md
@@ -45,13 +45,8 @@ The Following options temporary overwrites the config file settings:
-o, --url URL pool url and port, e.g. pool.usxmrpool.com:3333
-u, --user USERNAME pool user name or wallet address
-p, --pass PASSWD pool password, in the most cases x or empty ""
+```
## HTML and JSON API report configuraton
To configure the reports shown on the [README](README.md) side you need to edit the httpd_port variable. Then enable wifi on your phone and navigate to [miner ip address]:[httpd_port] in your phone browser. If you want to use the data in scripts, you can get the JSON version of the data at url [miner ip address]:[httpd_port]/api.json
-
-## Default Developer Donation
-By default the miner will donate 2% of the hashpower (2 minute in 100 minutes) to my pool. If you want to change that, edit **xmrstak/donate-level.hpp** before you build the binaries.
-
-If you want to donate directly to support further development, here is my wallet
-```
diff --git a/xmrstak/backend/amd/minethd.cpp b/xmrstak/backend/amd/minethd.cpp
index f12e12c..912587b 100644
--- a/xmrstak/backend/amd/minethd.cpp
+++ b/xmrstak/backend/amd/minethd.cpp
@@ -49,6 +49,7 @@ namespace amd
minethd::minethd(miner_work& pWork, size_t iNo, GpuContext* ctx, const jconf::thd_cfg cfg)
{
+ this->backendType = iBackend::AMD;
oWork = pWork;
bQuit = 0;
iThreadNo = (uint8_t)iNo;
diff --git a/xmrstak/backend/cpu/minethd.cpp b/xmrstak/backend/cpu/minethd.cpp
index d36ebf1..8b913cf 100644
--- a/xmrstak/backend/cpu/minethd.cpp
+++ b/xmrstak/backend/cpu/minethd.cpp
@@ -94,6 +94,7 @@ bool minethd::thd_setaffinity(std::thread::native_handle_type h, uint64_t cpu_id
minethd::minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefetch, int64_t affinity)
{
+ this->backendType = iBackend::CPU;
oWork = pWork;
bQuit = 0;
iThreadNo = (uint8_t)iNo;
diff --git a/xmrstak/backend/iBackend.hpp b/xmrstak/backend/iBackend.hpp
index ab964ce..dbfbc99 100644
--- a/xmrstak/backend/iBackend.hpp
+++ b/xmrstak/backend/iBackend.hpp
@@ -5,15 +5,31 @@
#include <atomic>
#include <cstdint>
#include <climits>
-
+#include <vector>
+#include <string>
namespace xmrstak
{
struct iBackend
{
+
+ enum BackendType : uint32_t { UNKNOWN = 0, CPU = 1u, AMD = 2u, NVIDIA = 3u };
+
+ static std::string getName(const BackendType type)
+ {
+ std::vector<std::string> backendNames = {
+ "UNKNOWN",
+ "CPU",
+ "AMD",
+ "NVIDIA"
+ };
+ return backendNames[static_cast<uint32_t>(type)];
+ }
+
std::atomic<uint64_t> iHashCount;
std::atomic<uint64_t> iTimestamp;
uint32_t iThreadNo;
+ BackendType backendType = UNKNOWN;
iBackend() : iHashCount(0), iTimestamp(0)
{
diff --git a/xmrstak/backend/nvidia/minethd.cpp b/xmrstak/backend/nvidia/minethd.cpp
index 0cf9a42..a1cafa7 100644
--- a/xmrstak/backend/nvidia/minethd.cpp
+++ b/xmrstak/backend/nvidia/minethd.cpp
@@ -66,6 +66,7 @@ namespace nvidia
minethd::minethd(miner_work& pWork, size_t iNo, const jconf::thd_cfg& cfg)
{
+ this->backendType = iBackend::NVIDIA;
oWork = pWork;
bQuit = 0;
iThreadNo = (uint8_t)iNo;
diff --git a/xmrstak/config.tpl b/xmrstak/config.tpl
index c06d121..c3ea061 100644
--- a/xmrstak/config.tpl
+++ b/xmrstak/config.tpl
@@ -106,7 +106,7 @@ POOLCONF],
*/
/*
- * use_slow_memory defines our behavior with regards to large pages. There are three possible options here:
+ * use_slow_memory defines our behaviour with regards to large pages. There are three possible options here:
* always - Don't even try to use large pages. Always use slow memory.
* warn - We will try to use large pages, but fall back to slow memory if that fails.
* no_mlck - This option is only relevant on Linux, where we can use large pages without locking memory.
@@ -159,6 +159,19 @@ POOLCONF],
"httpd_port" : 0,
/*
+ * HTTP Authentication
+ *
+ * This allows you to set a password to keep people on the Internet from snooping on your hashrate.
+ * Keep in mind that this is based on HTTP Digest, which is based on MD5. To a determined attacker
+ * who is able to read your traffic it is as easy to break a bog door latch.
+ *
+ * http_login - Login. Empty login disables authentication.
+ * http_pass - Password.
+ */
+"http_login" : "",
+"http_pass" : "",
+
+/*
* prefer_ipv4 - IPv6 preference. If the host is available on both IPv4 and IPv6 net, which one should be choose?
* This setting will only be needed in 2020's. No need to worry about it now.
*/
diff --git a/xmrstak/http/httpd.cpp b/xmrstak/http/httpd.cpp
index a112bbb..8debfa7 100644
--- a/xmrstak/http/httpd.cpp
+++ b/xmrstak/http/httpd.cpp
@@ -62,8 +62,32 @@ int httpd::req_handler(void * cls,
if (strcmp(method, "GET") != 0)
return MHD_NO;
- *ptr = nullptr;
+ if(strlen(jconf::inst()->GetHttpUsername()) != 0)
+ {
+ char* username;
+ int ret;
+
+ username = MHD_digest_auth_get_username(connection);
+ if (username == NULL)
+ {
+ rsp = MHD_create_response_from_buffer(sHtmlAccessDeniedSize, (void*)sHtmlAccessDenied, MHD_RESPMEM_PERSISTENT);
+ ret = MHD_queue_auth_fail_response(connection, sHttpAuthRelam, sHttpAuthOpaque, rsp, MHD_NO);
+ MHD_destroy_response(rsp);
+ return ret;
+ }
+ free(username);
+ ret = MHD_digest_auth_check(connection, sHttpAuthRelam, jconf::inst()->GetHttpUsername(), jconf::inst()->GetHttpPassword(), 300);
+ if (ret == MHD_INVALID_NONCE || ret == MHD_NO)
+ {
+ rsp = MHD_create_response_from_buffer(sHtmlAccessDeniedSize, (void*)sHtmlAccessDenied, MHD_RESPMEM_PERSISTENT);
+ ret = MHD_queue_auth_fail_response(connection, sHttpAuthRelam, sHttpAuthOpaque, rsp, (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO);
+ MHD_destroy_response(rsp);
+ return ret;
+ }
+ }
+
+ *ptr = nullptr;
std::string str;
if(strcasecmp(url, "/style.css") == 0)
{
diff --git a/xmrstak/http/webdesign.cpp b/xmrstak/http/webdesign.cpp
index 3b21ae0..3c33e1f 100644
--- a/xmrstak/http/webdesign.cpp
+++ b/xmrstak/http/webdesign.cpp
@@ -96,6 +96,17 @@ extern const char sHtmlCssFile [] =
size_t sHtmlCssSize = sizeof(sHtmlCssFile) - 1;
+extern const char sHttpAuthRelam[] = "XMR-Stak-Miner";
+extern const char sHttpAuthOpaque[] = "6c071f0df539e234cadbcd79164af7a594e23ab42bccb834df796aead6ce96e4";
+
+extern const char sHtmlAccessDenied[] =
+ "<!DOCTYPE html><html>"
+ "<head><title>Access Denied</title></head>"
+ "<body><h1>Access Denied</h1><p>You have entered a wrong username or password</p></body>"
+ "</html>";
+
+size_t sHtmlAccessDeniedSize = sizeof(sHtmlAccessDenied) - 1;
+
extern const char sHtmlCommonHeader [] =
"<!DOCTYPE html>"
"<html>"
diff --git a/xmrstak/http/webdesign.hpp b/xmrstak/http/webdesign.hpp
index 92639a0..122b5fb 100644
--- a/xmrstak/http/webdesign.hpp
+++ b/xmrstak/http/webdesign.hpp
@@ -4,6 +4,12 @@ extern const char sHtmlCssEtag[];
extern const char sHtmlCssFile[];
extern size_t sHtmlCssSize;
+extern const char sHtmlAccessDenied[];
+extern size_t sHtmlAccessDeniedSize;
+
+extern const char sHttpAuthRelam[];
+extern const char sHttpAuthOpaque[];
+
extern const char sHtmlCommonHeader[];
extern const char sHtmlHashrateBodyHigh[];
diff --git a/xmrstak/jconf.cpp b/xmrstak/jconf.cpp
index ec1233a..0418842 100644
--- a/xmrstak/jconf.cpp
+++ b/xmrstak/jconf.cpp
@@ -52,7 +52,7 @@ using namespace rapidjson;
*/
enum configEnum {
aPoolList, bTlsSecureAlgo, sCurrency, iCallTimeout, iNetRetry, iGiveUpLimit, iVerboseLevel, iAutohashTime,
- bFlushStdout, bDaemonMode, sOutputFile, iHttpdPort, bPreferIpv4, bAesOverride, sUseSlowMem
+ bFlushStdout, bDaemonMode, sOutputFile, iHttpdPort, sHttpLogin, sHttpPass, bPreferIpv4, bAesOverride, sUseSlowMem
};
struct configVal {
@@ -76,6 +76,8 @@ configVal oConfigValues[] = {
{ bDaemonMode, "daemon_mode", kTrueType },
{ sOutputFile, "output_file", kStringType },
{ iHttpdPort, "httpd_port", kNumberType },
+ { sHttpLogin, "http_login", kStringType },
+ { sHttpPass, "http_pass", kStringType },
{ bPreferIpv4, "prefer_ipv4", kTrueType },
{ bAesOverride, "aes_override", kNullType },
{ sUseSlowMem, "use_slow_memory", kStringType }
@@ -236,6 +238,16 @@ uint16_t jconf::GetHttpdPort()
return prv->configValues[iHttpdPort]->GetUint();
}
+const char* jconf::GetHttpUsername()
+{
+ return prv->configValues[sHttpLogin]->GetString();
+}
+
+const char* jconf::GetHttpPassword()
+{
+ return prv->configValues[sHttpPass]->GetString();
+}
+
bool jconf::DaemonMode()
{
return prv->configValues[bDaemonMode]->GetBool();
diff --git a/xmrstak/jconf.hpp b/xmrstak/jconf.hpp
index b68ef38..1bd4d47 100644
--- a/xmrstak/jconf.hpp
+++ b/xmrstak/jconf.hpp
@@ -60,6 +60,8 @@ public:
uint64_t GetGiveUpLimit();
uint16_t GetHttpdPort();
+ const char* GetHttpUsername();
+ const char* GetHttpPassword();
bool DaemonMode();
diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp
index 7d3a57d..454d1cf 100644
--- a/xmrstak/misc/executor.cpp
+++ b/xmrstak/misc/executor.cpp
@@ -29,6 +29,7 @@
#include "xmrstak/backend/miner_work.hpp"
#include "xmrstak/backend/globalStates.hpp"
#include "xmrstak/backend/backendConnector.hpp"
+#include "xmrstak/backend/iBackend.hpp"
#include "xmrstak/jconf.hpp"
#include "xmrstak/misc/console.hpp"
@@ -451,8 +452,26 @@ void executor::on_miner_result(size_t pool_id, job_result& oResult)
}
}
+#ifndef _WIN32
+
+#include <signal.h>
+void disable_sigpipe()
+{
+ struct sigaction sa;
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ if (sigaction(SIGPIPE, &sa, 0) == -1)
+ printer::inst()->print_msg(L1, "ERROR: Call to sigaction failed!");
+}
+
+#else
+inline void disable_sigpipe() {}
+#endif
+
void executor::ex_main()
{
+ disable_sigpipe();
+
assert(1000 % iTickTime == 0);
xmrstak::miner_work oWork = xmrstak::miner_work();
@@ -603,49 +622,64 @@ inline const char* hps_format(double h, char* buf, size_t l)
void executor::hashrate_report(std::string& out)
{
char num[32];
- size_t nthd = pvThreads->size();
-
- out.reserve(256 + nthd * 64);
-
double fTotal[3] = { 0.0, 0.0, 0.0};
- size_t i;
-
- out.append("HASHRATE REPORT\n");
- out.append("| ID | 10s | 60s | 15m |");
- if(nthd != 1)
- out.append(" ID | 10s | 60s | 15m |\n");
- else
- out.append(1, '\n');
- for (i = 0; i < nthd; i++)
+ for( uint32_t b = 0; b < 4u; ++b)
{
- double fHps[3];
+ std::vector<xmrstak::iBackend*> backEnds;
+ std::copy_if(pvThreads->begin(), pvThreads->end(), std::back_inserter(backEnds),
+ [&](xmrstak::iBackend* backend)
+ {
+ return backend->backendType == b;
+ }
+ );
- fHps[0] = telem->calc_telemetry_data(10000, i);
- fHps[1] = telem->calc_telemetry_data(60000, i);
- fHps[2] = telem->calc_telemetry_data(900000, i);
+ size_t nthd = backEnds.size();
+ if(nthd != 0)
+ {
+ out.reserve(256 + nthd * 64);
+
+ size_t i;
+ auto bType = static_cast<xmrstak::iBackend::BackendType>(b);
+ out.append("HASHRATE REPORT - ").append(xmrstak::iBackend::getName(bType)).append("\n");
+ out.append("| ID | 10s | 60s | 15m |");
+ if(nthd != 1)
+ out.append(" ID | 10s | 60s | 15m |\n");
+ else
+ out.append(1, '\n');
- snprintf(num, sizeof(num), "| %2u |", (unsigned int)i);
- out.append(num);
- out.append(hps_format(fHps[0], num, sizeof(num))).append(" |");
- out.append(hps_format(fHps[1], num, sizeof(num))).append(" |");
- out.append(hps_format(fHps[2], num, sizeof(num))).append(1, ' ');
+ for (i = 0; i < nthd; i++)
+ {
+ double fHps[3];
- fTotal[0] += fHps[0];
- fTotal[1] += fHps[1];
- fTotal[2] += fHps[2];
+ uint32_t tid = backEnds[i]->iThreadNo;
+ fHps[0] = telem->calc_telemetry_data(10000, tid);
+ fHps[1] = telem->calc_telemetry_data(60000, tid);
+ fHps[2] = telem->calc_telemetry_data(900000, tid);
- if((i & 0x1) == 1) //Odd i's
- out.append("|\n");
- }
+ snprintf(num, sizeof(num), "| %2u |", (unsigned int)i);
+ out.append(num);
+ out.append(hps_format(fHps[0], num, sizeof(num))).append(" |");
+ out.append(hps_format(fHps[1], num, sizeof(num))).append(" |");
+ out.append(hps_format(fHps[2], num, sizeof(num))).append(1, ' ');
- if((i & 0x1) == 1) //We had odd number of threads
- out.append("|\n");
+ fTotal[0] += fHps[0];
+ fTotal[1] += fHps[1];
+ fTotal[2] += fHps[2];
- if(nthd != 1)
- out.append("-----------------------------------------------------\n");
- else
- out.append("---------------------------\n");
+ if((i & 0x1) == 1) //Odd i's
+ out.append("|\n");
+ }
+
+ if((i & 0x1) == 1) //We had odd number of threads
+ out.append("|\n");
+
+ if(nthd != 1)
+ out.append("-----------------------------------------------------\n");
+ else
+ out.append("---------------------------\n");
+ }
+ }
out.append("Totals: ");
out.append(hps_format(fTotal[0], num, sizeof(num)));
OpenPOWER on IntegriCloud