mirror of
https://github.com/xmrig/xmrig-proxy.git
synced 2026-02-11 20:19:17 +08:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8654d411b | ||
|
|
2e149582b9 | ||
|
|
e1d82fe8f0 | ||
|
|
011a2050d1 | ||
|
|
0581513570 | ||
|
|
5117034c17 | ||
|
|
9b1aab91df | ||
|
|
d683a8f5c1 | ||
|
|
b099bdbf11 | ||
|
|
40041cd7cb | ||
|
|
6df80209b2 | ||
|
|
cff12d49fe | ||
|
|
bae9edcf35 | ||
|
|
589c87cfa0 | ||
|
|
7c509b4714 | ||
|
|
fc35957d83 | ||
|
|
f65b647791 | ||
|
|
eede0a9935 | ||
|
|
24cea5ca07 | ||
|
|
4328daf835 | ||
|
|
b74b9a1196 | ||
|
|
2585dac204 | ||
|
|
393364b67f | ||
|
|
a1f52905a6 | ||
|
|
682f1be7e4 | ||
|
|
054ecc64df | ||
|
|
f6079fdc65 | ||
|
|
598f04fe21 | ||
|
|
9f2a049013 |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,4 +1,14 @@
|
||||
# v4.5.0-beta
|
||||
# v5.4.0
|
||||
- [#1434](https://github.com/xmrig/xmrig/pull/1434) Added RandomSFX (`rx/sfx`) algorithm for Safex Cash.
|
||||
- [#1445](https://github.com/xmrig/xmrig/pull/1445) Added RandomV (`rx/v`) algorithm for *new* MoneroV.
|
||||
- [#367](https://github.com/xmrig/xmrig-proxy/issues/367) Added "cert-key" alias, fixed --tls-cert-key command line option.
|
||||
|
||||
# v5.0.1
|
||||
- **Fixed memory leak.**
|
||||
- Fixed crash if no valid configuration found.
|
||||
- Other minor fixes.
|
||||
|
||||
# v5.0.0
|
||||
- Proxy rebased to latest miner codebase.
|
||||
- [#1068](https://github.com/xmrig/xmrig/pull/1068) Added support for `self-select` stratum protocol extension.
|
||||
- [#1227](https://github.com/xmrig/xmrig/pull/1227) Added new algorithm `rx/arq`, RandomX variant for upcoming ArQmA fork.
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
# - Try to find MHD
|
||||
# Once done this will define
|
||||
#
|
||||
# MHD_FOUND - system has MHD
|
||||
# MHD_INCLUDE_DIRS - the MHD include directory
|
||||
# MHD_LIBRARY - Link these to use MHD
|
||||
|
||||
find_path(
|
||||
MHD_INCLUDE_DIR
|
||||
NAMES microhttpd.h
|
||||
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
|
||||
PATH_SUFFIXES "include"
|
||||
DOC "microhttpd include dir"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
find_path(MHD_INCLUDE_DIR NAMES microhttpd.h)
|
||||
|
||||
find_library(
|
||||
MHD_LIBRARY
|
||||
NAMES libmicrohttpd.a microhttpd libmicrohttpd
|
||||
PATHS "${XMRIG_DEPS}" ENV "XMRIG_DEPS"
|
||||
PATH_SUFFIXES "lib"
|
||||
DOC "microhttpd library"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
find_library(MHD_LIBRARY NAMES microhttpd libmicrohttpd)
|
||||
|
||||
set(MHD_INCLUDE_DIRS ${MHD_INCLUDE_DIR})
|
||||
set(MHD_LIBRARIES ${MHD_LIBRARY})
|
||||
|
||||
# debug library on windows
|
||||
# same naming convention as in qt (appending debug library with d)
|
||||
# boost is using the same "hack" as us with "optimized" and "debug"
|
||||
# official MHD project actually uses _d suffix
|
||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
|
||||
find_library(
|
||||
MHD_LIBRARY_DEBUG
|
||||
NAMES microhttpd_d microhttpd-10_d libmicrohttpd_d libmicrohttpd-dll_d
|
||||
DOC "mhd debug library"
|
||||
)
|
||||
set(MHD_LIBRARIES optimized ${MHD_LIBRARIES} debug ${MHD_LIBRARY_DEBUG})
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(MHD DEFAULT_MSG MHD_LIBRARY MHD_INCLUDE_DIR)
|
||||
mark_as_advanced(MHD_INCLUDE_DIR MHD_LIBRARY)
|
||||
|
||||
@@ -6,6 +6,8 @@ if (WITH_TLS)
|
||||
set(OPENSSL_MSVC_STATIC_RT TRUE)
|
||||
|
||||
set(EXTRA_LIBS ${EXTRA_LIBS} Crypt32)
|
||||
elseif (APPLE)
|
||||
set(OPENSSL_USE_STATIC_LIBS TRUE)
|
||||
endif()
|
||||
|
||||
find_package(OpenSSL)
|
||||
|
||||
30
doc/gpg_keys/xmrig.asc
Normal file
30
doc/gpg_keys/xmrig.asc
Normal file
@@ -0,0 +1,30 @@
|
||||
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
||||
|
||||
mQENBF3VSRIBCADfFjDUbq0WLGulFeSou0A+jTvweNllPyLNOn3SNCC0XLEYyEcu
|
||||
JiEBK80DlvR06TVr8Aw1rT5S2iH0i5Tl8DqShH2mmcN1rBp1M0Y95D89KVj3BIhE
|
||||
nxmgmD4N3Wgm+5FmEH4W/RpG1xdYWJx3eJhtWPdFJqpg083E2D5P30wIQem+EnTR
|
||||
5YrtTZPh5cPj2KRY+UmsDE3ahmxCgP7LYgnnpZQlWBBiMV932s7MvYBPJQc1wecS
|
||||
0wi1zxyS81xHc3839EkA7wueCeNo+5jha+KH66tMKsfrI2WvfPHTCPjK9v7WJc/O
|
||||
/eRp9d+wacn09D1L6CoRO0ers5p10GO84VhTABEBAAG0GVhNUmlnIDxzdXBwb3J0
|
||||
QHhtcmlnLmNvbT6JAU4EEwEIADgWIQSaxM6o5m41pcfN3BtEalNji+lECQUCXdVJ
|
||||
EgIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRBEalNji+lECbkQB/9nRou0
|
||||
tOlBwYn8xVgBu7IiDWNVETRWfrjrtdTvSahgbbo6lWgjA/vBLkjN9fISdBQ/n/Mt
|
||||
hNDJbEtxHHt2baJhvT8du1eWcIHHXCV/rmv+iY/hTXa1gKqHiHDJrtYSVBG3BMme
|
||||
1rdsUHTiKf3t5yRHOXAfY2C+XNblKAV7mhlxQBiKxdFDIkFEQKNrHNUvnzkOqoCT
|
||||
2kTZZ2tPUMQdOn1eek6zG/+C7SwcBpJnakJ8jce4yA/xZbOVKetNWO3Ufu3TE34k
|
||||
OdA+H4PU9+fV77XfOY8DtXeS3boUI97ei+4s/mwX/NFC0i8CPXyefxl3WRUBGDOI
|
||||
w//kPNQVh4HobOCeuQENBF3VSRIBCADl29WorEi+vRA/3kg9VUXtxSU6caibFS3N
|
||||
VXANiFRjrOmICdfrIgOSGNrYCQFsXu0Xe0udDYVX8yX6WJk+CT02Pdg0gkXiKoze
|
||||
KrnK15mo3xXbb2tr1o9ROPgwY/o2AwQHj0o1JhdS2cybfuRiUQRoGgBX7a9X0cTY
|
||||
r4ZJvOjzgAajl3ciwB3yWUmDiRlzZpO7YWESXbOhGVzyCnP5MlMEJ/fPRw9h38vK
|
||||
HNKLhzcRfsLpXk34ghY3SxIv4NWUfuZXFWqpSdC9JgNc5zA72lJEQcF4DHJCKl7B
|
||||
ddmrfsr9mdiIpo+/ZZFPPngdeZ2kvkJ2YKaZNVu2XooJARPQ8B8tABEBAAGJATYE
|
||||
GAEIACAWIQSaxM6o5m41pcfN3BtEalNji+lECQUCXdVJEgIbDAAKCRBEalNji+lE
|
||||
CdPUB/4nH1IdhHGmfko2kxdaHqQgCGLqh3pcrQXD9mBv/LYVnoHZpVRHsIDgg2Z4
|
||||
lQYrIRRqe69FjVxo7sA2eMIlV0GRDlUrw+HeURFpEhKPEdwFy6i/cti2MY0YxOrB
|
||||
TvQoRutUoMnyjM4TBJWaaqccbTsavMdLmG3JHdAkiHtUis/fUwVctmEQwN+d/J2b
|
||||
wJAtliqw3nXchUfdIfwHF/7hg8seUuYUaifzkazBZhVWvRkTVLVanzZ51HRfuzwD
|
||||
ntaa7kfYGdE+4TKOylAPh+8E6WnR19RRTpsaW0dVBgOiBTE0uc7rUv2HWS/u6RUR
|
||||
t7ldSBzkuDTlM2V59Iq2hXoSC6dT
|
||||
=cIG9
|
||||
-----END PGP PUBLIC KEY BLOCK-----
|
||||
3
doc/releases/5_0_0/SHA256SUMS
Normal file
3
doc/releases/5_0_0/SHA256SUMS
Normal file
@@ -0,0 +1,3 @@
|
||||
e12d814f584cecbb6cec9c394e49989f53ae61d4079c51c7682d938a03963b96 xmrig-proxy-5.0.0-gcc-win32.zip
|
||||
0a5e143c979ef163247439da3049492ecfad49355e34ae371b14a8e08529230e xmrig-proxy-5.0.0-msvc-win64.zip
|
||||
af7564afbb7e69aea52e6a2a945cb04caa09a993a468d5c1fdd73c3d337da05e xmrig-proxy-5.0.0-xenial-x64.tar.gz
|
||||
11
doc/releases/5_0_0/SHA256SUMS.sig
Normal file
11
doc/releases/5_0_0/SHA256SUMS.sig
Normal file
@@ -0,0 +1,11 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
|
||||
iQEzBAABCgAdFiEEmsTOqOZuNaXHzdwbRGpTY4vpRAkFAl3Vl4YACgkQRGpTY4vp
|
||||
RAlj+Qf/TeSwcQ7HoDeCk7kAVTu25gZDf/gqTyYVNPt8x4pSjc0ofxXNo/q0Yrla
|
||||
Dy5Ovjy0ZHJVYAC3vYdaDEaTWkZ0DVCytYDHEtsOgaA4jQm5baHGyIjREq1II8sl
|
||||
QU27VhiOsX39jxrV4bGJvSkgLRpljFSIlbwn8+yP+sCwPMJ4MMEoJCC60agIsZBu
|
||||
PsJQGVxAJ/n3nk2zvUuz/5DGqFyeOJ2MjqnLcaP6IoJ/PHxUngVi7k9qIggi6EFg
|
||||
Ou/M0VMNpSo9uengCKoOsidtTkoek3MXGw+eS/JVB0qNCGHaNHqj3bTRD8yk7Klv
|
||||
qq5hC4F84jAPPO8QHago9n4UcoYSkQ==
|
||||
=M0Ty
|
||||
-----END PGP SIGNATURE-----
|
||||
41
src/App.cpp
41
src/App.cpp
@@ -22,8 +22,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
@@ -38,18 +38,9 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
xmrig::App::App(Process *process) :
|
||||
m_console(nullptr),
|
||||
m_signals(nullptr)
|
||||
xmrig::App::App(Process *process)
|
||||
{
|
||||
m_controller = new Controller(process);
|
||||
if (m_controller->init() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_controller->config()->isBackground()) {
|
||||
m_console = new Console(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,19 +54,39 @@ xmrig::App::~App()
|
||||
|
||||
int xmrig::App::exec()
|
||||
{
|
||||
if (!m_controller->config()) {
|
||||
if (!m_controller->isReady()) {
|
||||
LOG_EMERG("no valid configuration found.");
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
m_signals = new Signals(this);
|
||||
|
||||
background();
|
||||
int rc = 0;
|
||||
if (background(rc)) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = m_controller->init();
|
||||
if (rc != 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (!m_controller->isBackground()) {
|
||||
m_console = new Console(this);
|
||||
}
|
||||
|
||||
Summary::print(m_controller);
|
||||
|
||||
if (m_controller->config()->isDryRun()) {
|
||||
LOG_NOTICE("OK");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
m_controller->start();
|
||||
|
||||
const int rc = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
rc = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
uv_loop_close(uv_default_loop());
|
||||
|
||||
return rc;
|
||||
|
||||
14
src/App.h
14
src/App.h
@@ -28,9 +28,7 @@
|
||||
|
||||
#include "base/kernel/interfaces/IConsoleListener.h"
|
||||
#include "base/kernel/interfaces/ISignalListener.h"
|
||||
|
||||
|
||||
class Proxy;
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -45,6 +43,8 @@ class Signals;
|
||||
class App : public IConsoleListener, public ISignalListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(App)
|
||||
|
||||
App(Process *process);
|
||||
~App() override;
|
||||
|
||||
@@ -55,12 +55,12 @@ protected:
|
||||
void onSignal(int signum) override;
|
||||
|
||||
private:
|
||||
void background();
|
||||
bool background(int &rc);
|
||||
void close();
|
||||
|
||||
Console *m_console;
|
||||
Controller *m_controller;
|
||||
Signals *m_signals;
|
||||
Console *m_console = nullptr;
|
||||
Controller *m_controller = nullptr;
|
||||
Signals *m_signals = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -22,33 +22,37 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <csignal>
|
||||
#include <cerrno>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include "App.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
|
||||
|
||||
void xmrig::App::background()
|
||||
bool xmrig::App::background(int &rc)
|
||||
{
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
if (!m_controller->config()->isBackground()) {
|
||||
return;
|
||||
if (!m_controller->isBackground()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int i = fork();
|
||||
if (i < 0) {
|
||||
exit(1);
|
||||
rc = 1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
exit(0);
|
||||
rc = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
i = setsid();
|
||||
@@ -61,4 +65,6 @@ void xmrig::App::background()
|
||||
if (i < 0) {
|
||||
LOG_ERR("chdir() failed (errno = %d)", errno);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,14 +28,13 @@
|
||||
|
||||
|
||||
#include "App.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
|
||||
|
||||
void xmrig::App::background()
|
||||
bool xmrig::App::background(int &)
|
||||
{
|
||||
if (!m_controller->config()->isBackground()) {
|
||||
return;
|
||||
if (!m_controller->isBackground()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
HWND hcon = GetConsoleWindow();
|
||||
@@ -46,4 +45,6 @@ void xmrig::App::background()
|
||||
CloseHandle(h);
|
||||
FreeConsole();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
@@ -35,18 +35,21 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static void print_mode(xmrig::Controller *controller)
|
||||
{
|
||||
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") MAGENTA_BOLD("%s"), "MODE", controller->config()->modeName());
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") MAGENTA_BOLD("%s"), "MODE", controller->config()->modeName());
|
||||
}
|
||||
|
||||
|
||||
static void print_bind(xmrig::Controller *controller)
|
||||
{
|
||||
const xmrig::BindHosts &bind = controller->config()->bind();
|
||||
const BindHosts &bind = controller->config()->bind();
|
||||
|
||||
for (size_t i = 0; i < bind.size(); ++i) {
|
||||
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("BIND #%-7zu") CYAN("%s%s%s:") "\x1B[1;%dm%d\x1B[0m",
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("BIND #%-7zu") CYAN("%s%s%s:") "\x1B[1;%dm%d\x1B[0m",
|
||||
i + 1,
|
||||
bind[i].isIPv6() ? "[" : "",
|
||||
bind[i].host(),
|
||||
@@ -59,18 +62,21 @@ static void print_bind(xmrig::Controller *controller)
|
||||
|
||||
static void print_commands(xmrig::Controller *)
|
||||
{
|
||||
if (xmrig::Log::colors) {
|
||||
xmrig::Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BOLD("h") WHITE_BOLD("ashrate, ")
|
||||
if (Log::isColors()) {
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("COMMANDS ") MAGENTA_BOLD("h") WHITE_BOLD("ashrate, ")
|
||||
MAGENTA_BOLD("c") WHITE_BOLD("onnections, ")
|
||||
MAGENTA_BOLD("v") WHITE_BOLD("erbose, ")
|
||||
MAGENTA_BOLD("w") WHITE_BOLD("orkers"));
|
||||
}
|
||||
else {
|
||||
xmrig::Log::print(" * COMMANDS 'h' hashrate, 'c' connections, 'v' verbose, 'w' workers");
|
||||
Log::print(" * COMMANDS 'h' hashrate, 'c' connections, 'v' verbose, 'w' workers");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
void Summary::print(xmrig::Controller *controller)
|
||||
{
|
||||
controller->config()->printVersions();
|
||||
|
||||
@@ -22,14 +22,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <string.h>
|
||||
#include <uv.h>
|
||||
#include <thread>
|
||||
|
||||
|
||||
#include "base/api/interfaces/IApiRequest.h"
|
||||
#include "api/v1/ApiRouter.h"
|
||||
#include "base/api/interfaces/IApiRequest.h"
|
||||
#include "base/kernel/Platform.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "core/config/Config.h"
|
||||
@@ -41,6 +35,11 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
static inline double normalize(double d)
|
||||
{
|
||||
if (!std::isnormal(d)) {
|
||||
@@ -57,9 +56,7 @@ xmrig::ApiRouter::ApiRouter(Base *base) :
|
||||
}
|
||||
|
||||
|
||||
xmrig::ApiRouter::~ApiRouter()
|
||||
{
|
||||
}
|
||||
xmrig::ApiRouter::~ApiRouter() = default;
|
||||
|
||||
|
||||
void xmrig::ApiRouter::onRequest(IApiRequest &request)
|
||||
@@ -69,7 +66,6 @@ void xmrig::ApiRouter::onRequest(IApiRequest &request)
|
||||
request.accept();
|
||||
getMiner(request.reply(), request.doc());
|
||||
getHashrate(request.reply(), request.doc());
|
||||
getResourcesSummary(request.reply(), request.doc());
|
||||
getMinersSummary(request.reply(), request.doc());
|
||||
getResults(request.reply(), request.doc());
|
||||
}
|
||||
@@ -196,36 +192,6 @@ void xmrig::ApiRouter::getMinersSummary(rapidjson::Value &reply, rapidjson::Docu
|
||||
}
|
||||
|
||||
|
||||
|
||||
void xmrig::ApiRouter::getResourcesSummary(rapidjson::Value &reply, rapidjson::Document &doc) const
|
||||
{
|
||||
using namespace rapidjson;
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
size_t rss = 0;
|
||||
uv_resident_set_memory(&rss);
|
||||
|
||||
Value resources(kObjectType);
|
||||
Value memory(kObjectType);
|
||||
Value load_average(kArrayType);
|
||||
|
||||
memory.AddMember("total", uv_get_total_memory(), allocator);
|
||||
memory.AddMember("resident_set_memory", static_cast<uint64_t>(rss), allocator);
|
||||
|
||||
double loadavg[3] = { 1.0 };
|
||||
uv_loadavg(loadavg);
|
||||
load_average.PushBack(loadavg[0], allocator);
|
||||
load_average.PushBack(loadavg[1], allocator);
|
||||
load_average.PushBack(loadavg[2], allocator);
|
||||
|
||||
resources.AddMember("memory", memory, allocator);
|
||||
resources.AddMember("load_average", load_average, allocator);
|
||||
resources.AddMember("hardware_concurrency", std::thread::hardware_concurrency(), allocator);
|
||||
|
||||
reply.AddMember("resources", resources, allocator);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::ApiRouter::getResults(rapidjson::Value &reply, rapidjson::Document &doc) const
|
||||
{
|
||||
auto &allocator = doc.GetAllocator();
|
||||
@@ -243,8 +209,8 @@ void xmrig::ApiRouter::getResults(rapidjson::Value &reply, rapidjson::Document &
|
||||
results.AddMember("hashes_donate", stats.donateHashes, allocator);
|
||||
|
||||
rapidjson::Value best(rapidjson::kArrayType);
|
||||
for (size_t i = 0; i < stats.topDiff.size(); ++i) {
|
||||
best.PushBack(stats.topDiff[i], allocator);
|
||||
for (uint64_t i : stats.topDiff) {
|
||||
best.PushBack(i, allocator);
|
||||
}
|
||||
|
||||
results.AddMember("best", best, allocator);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
|
||||
#include "base/api/interfaces/IApiListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "proxy/StatsData.h"
|
||||
#include "rapidjson/fwd.h"
|
||||
|
||||
@@ -40,6 +41,8 @@ class Base;
|
||||
class ApiRouter : public xmrig::IApiListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(ApiRouter)
|
||||
|
||||
ApiRouter(Base *base);
|
||||
~ApiRouter() override;
|
||||
|
||||
@@ -52,7 +55,6 @@ private:
|
||||
void getMiner(rapidjson::Value &reply, rapidjson::Document &doc) const;
|
||||
void getMiners(rapidjson::Value &reply, rapidjson::Document &doc) const;
|
||||
void getMinersSummary(rapidjson::Value &reply, rapidjson::Document &doc) const;
|
||||
void getResourcesSummary(rapidjson::Value &reply, rapidjson::Document &doc) const;
|
||||
void getResults(rapidjson::Value &reply, rapidjson::Document &doc) const;
|
||||
void getWorkers(rapidjson::Value &reply, rapidjson::Document &doc) const;
|
||||
|
||||
|
||||
@@ -31,10 +31,11 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/api/Api.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/api/interfaces/IApiListener.h"
|
||||
#include "base/api/requests/HttpApiRequest.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/kernel/Base.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
@@ -49,12 +50,49 @@
|
||||
#endif
|
||||
|
||||
|
||||
#include <thread>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static rapidjson::Value getResources(rapidjson::Document &doc)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
auto &allocator = doc.GetAllocator();
|
||||
|
||||
size_t rss = 0;
|
||||
uv_resident_set_memory(&rss);
|
||||
|
||||
Value out(kObjectType);
|
||||
Value memory(kObjectType);
|
||||
Value load_average(kArrayType);
|
||||
|
||||
memory.AddMember("free", uv_get_free_memory(), allocator);
|
||||
memory.AddMember("total", uv_get_total_memory(), allocator);
|
||||
memory.AddMember("resident_set_memory", static_cast<uint64_t>(rss), allocator);
|
||||
|
||||
double loadavg[3] = { 0.0 };
|
||||
uv_loadavg(loadavg);
|
||||
|
||||
for (double value : loadavg) {
|
||||
load_average.PushBack(Json::normalize(value, true), allocator);
|
||||
}
|
||||
|
||||
out.AddMember("memory", memory, allocator);
|
||||
out.AddMember("load_average", load_average, allocator);
|
||||
out.AddMember("hardware_concurrency", std::thread::hardware_concurrency(), allocator);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::Api::Api(Base *base) :
|
||||
m_base(base),
|
||||
m_id(),
|
||||
m_workerId(),
|
||||
m_timestamp(Chrono::currentMSecsSinceEpoch()),
|
||||
m_httpd(nullptr)
|
||||
m_timestamp(Chrono::currentMSecsSinceEpoch())
|
||||
{
|
||||
base->addListener(this);
|
||||
|
||||
@@ -117,10 +155,13 @@ void xmrig::Api::exec(IApiRequest &request)
|
||||
auto &allocator = request.doc().GetAllocator();
|
||||
|
||||
request.accept();
|
||||
request.reply().AddMember("id", StringRef(m_id), allocator);
|
||||
request.reply().AddMember("worker_id", StringRef(m_workerId), allocator);
|
||||
request.reply().AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);
|
||||
request.reply().AddMember("restricted", request.isRestricted(), allocator);
|
||||
|
||||
auto &reply = request.reply();
|
||||
reply.AddMember("id", StringRef(m_id), allocator);
|
||||
reply.AddMember("worker_id", StringRef(m_workerId), allocator);
|
||||
reply.AddMember("uptime", (Chrono::currentMSecsSinceEpoch() - m_timestamp) / 1000, allocator);
|
||||
reply.AddMember("restricted", request.isRestricted(), allocator);
|
||||
reply.AddMember("resources", getResources(request.doc()), allocator);
|
||||
|
||||
Value features(kArrayType);
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
@@ -144,7 +185,10 @@ void xmrig::Api::exec(IApiRequest &request)
|
||||
# ifdef XMRIG_FEATURE_OPENCL
|
||||
features.PushBack("opencl", allocator);
|
||||
# endif
|
||||
request.reply().AddMember("features", features, allocator);
|
||||
# ifdef XMRIG_FEATURE_CUDA
|
||||
features.PushBack("cuda", allocator);
|
||||
# endif
|
||||
reply.AddMember("features", features, allocator);
|
||||
}
|
||||
|
||||
for (IApiListener *listener : m_listeners) {
|
||||
@@ -179,13 +223,13 @@ void xmrig::Api::genId(const String &id)
|
||||
if (!interfaces[i].is_internal && interfaces[i].address.address4.sin_family == AF_INET) {
|
||||
uint8_t hash[200];
|
||||
const size_t addrSize = sizeof(interfaces[i].phys_addr);
|
||||
const size_t inSize = strlen(APP_KIND) + addrSize + sizeof(uint16_t);
|
||||
const uint16_t port = static_cast<uint16_t>(m_base->config()->http().port());
|
||||
const size_t inSize = (sizeof(APP_KIND) - 1) + addrSize + sizeof(uint16_t);
|
||||
const auto port = static_cast<uint16_t>(m_base->config()->http().port());
|
||||
|
||||
uint8_t *input = new uint8_t[inSize]();
|
||||
auto*input = new uint8_t[inSize]();
|
||||
memcpy(input, &port, sizeof(uint16_t));
|
||||
memcpy(input + sizeof(uint16_t), interfaces[i].phys_addr, addrSize);
|
||||
memcpy(input + sizeof(uint16_t) + addrSize, APP_KIND, strlen(APP_KIND));
|
||||
memcpy(input + sizeof(uint16_t) + addrSize, APP_KIND, (sizeof(APP_KIND) - 1));
|
||||
|
||||
keccak(input, inSize, hash);
|
||||
Buffer::toHex(hash, 8, m_id);
|
||||
|
||||
@@ -70,10 +70,10 @@ private:
|
||||
void genWorkerId(const String &id);
|
||||
|
||||
Base *m_base;
|
||||
char m_id[32];
|
||||
char m_workerId[128];
|
||||
char m_id[32]{};
|
||||
char m_workerId[128]{};
|
||||
const uint64_t m_timestamp;
|
||||
Httpd *m_httpd;
|
||||
Httpd *m_httpd = nullptr;
|
||||
std::vector<IApiListener *> m_listeners;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "base/api/Httpd.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/api/Api.h"
|
||||
#include "base/api/Httpd.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/http/HttpApiResponse.h"
|
||||
#include "base/net/http/HttpData.h"
|
||||
@@ -58,9 +58,7 @@ xmrig::Httpd::Httpd(Base *base) :
|
||||
}
|
||||
|
||||
|
||||
xmrig::Httpd::~Httpd()
|
||||
{
|
||||
}
|
||||
xmrig::Httpd::~Httpd() = default;
|
||||
|
||||
|
||||
bool xmrig::Httpd::start()
|
||||
|
||||
@@ -26,11 +26,12 @@
|
||||
#define XMRIG_HTTPD_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/IBaseListener.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -44,6 +45,8 @@ class TcpServer;
|
||||
class Httpd : public IBaseListener, public IHttpListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Httpd)
|
||||
|
||||
Httpd(Base *base);
|
||||
~Httpd() override;
|
||||
|
||||
|
||||
@@ -33,6 +33,4 @@ xmrig::ApiRequest::ApiRequest(Source source, bool restricted) :
|
||||
}
|
||||
|
||||
|
||||
xmrig::ApiRequest::~ApiRequest()
|
||||
{
|
||||
}
|
||||
xmrig::ApiRequest::~ApiRequest() = default;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "base/api/interfaces/IApiRequest.h"
|
||||
#include "base/tools/String.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -37,6 +38,8 @@ namespace xmrig {
|
||||
class ApiRequest : public IApiRequest
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(ApiRequest)
|
||||
|
||||
ApiRequest(Source source, bool restricted);
|
||||
~ApiRequest() override;
|
||||
|
||||
@@ -63,8 +66,8 @@ protected:
|
||||
String m_rpcMethod;
|
||||
|
||||
private:
|
||||
bool m_restricted;
|
||||
Source m_source;
|
||||
const bool m_restricted;
|
||||
const Source m_source;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -50,7 +51,7 @@ bool xmrig::Json::getBool(const rapidjson::Value &obj, const char *key, bool def
|
||||
}
|
||||
|
||||
|
||||
const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key, const char *defaultValue)
|
||||
const char *xmrig::Json::getString(const rapidjson::Value &obj, const char *key, const char *defaultValue)
|
||||
{
|
||||
assert(obj.IsObject());
|
||||
|
||||
@@ -154,6 +155,18 @@ unsigned xmrig::Json::getUint(const rapidjson::Value &obj, const char *key, unsi
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Value xmrig::Json::normalize(double value, bool zero)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
||||
if (!std::isnormal(value)) {
|
||||
return zero ? Value(0.0) : Value(kNullType);
|
||||
}
|
||||
|
||||
return Value(floor(value * 100.0) / 100.0);
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::JsonReader::isEmpty() const
|
||||
{
|
||||
return !m_obj.IsObject() || m_obj.ObjectEmpty();
|
||||
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
|
||||
static bool get(const char *fileName, rapidjson::Document &doc);
|
||||
static bool save(const char *fileName, const rapidjson::Document &doc);
|
||||
|
||||
static rapidjson::Value normalize(double value, bool zero);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
|
||||
if (Log::background && m_backends.empty()) {
|
||||
if (Log::isBackground() && m_backends.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -195,9 +195,10 @@ private:
|
||||
};
|
||||
|
||||
|
||||
bool Log::background = false;
|
||||
bool Log::colors = true;
|
||||
LogPrivate *Log::d = new LogPrivate();
|
||||
bool Log::m_background = false;
|
||||
bool Log::m_colors = true;
|
||||
LogPrivate *Log::d = new LogPrivate();
|
||||
uint32_t Log::m_verbose = 0;
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#define XMRIG_LOG_H
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@@ -54,10 +57,19 @@ public:
|
||||
static void print(const char *fmt, ...);
|
||||
static void print(Level level, const char *fmt, ...);
|
||||
|
||||
static bool background;
|
||||
static bool colors;
|
||||
static inline bool isBackground() { return m_background; }
|
||||
static inline bool isColors() { return m_colors; }
|
||||
static inline bool isVerbose() { return m_verbose > 0; }
|
||||
static inline uint32_t verbose() { return m_verbose; }
|
||||
static inline void setBackground(bool background) { m_background = background; }
|
||||
static inline void setColors(bool colors) { m_colors = colors; }
|
||||
static inline void setVerbose(uint32_t verbose) { m_verbose = verbose; }
|
||||
|
||||
private:
|
||||
static bool m_background;
|
||||
static bool m_colors;
|
||||
static uint32_t m_verbose;
|
||||
|
||||
static LogPrivate *d;
|
||||
};
|
||||
|
||||
@@ -83,6 +95,7 @@ private:
|
||||
#define WHITE_BOLD_S CSI "1;37m" // actually white
|
||||
|
||||
#define GREEN_BG_BOLD_S CSI "42;1m"
|
||||
#define YELLOW_BG_BOLD_S CSI "43;1m"
|
||||
#define BLUE_BG_S CSI "44m"
|
||||
#define BLUE_BG_BOLD_S CSI "44;1m"
|
||||
#define MAGENTA_BG_S CSI "45m"
|
||||
@@ -109,6 +122,7 @@ private:
|
||||
#define WHITE_BOLD(x) WHITE_BOLD_S x CLEAR
|
||||
|
||||
#define GREEN_BG_BOLD(x) GREEN_BG_BOLD_S x CLEAR
|
||||
#define YELLOW_BG_BOLD(x) YELLOW_BG_BOLD_S x CLEAR
|
||||
#define BLUE_BG(x) BLUE_BG_S x CLEAR
|
||||
#define BLUE_BG_BOLD(x) BLUE_BG_BOLD_S x CLEAR
|
||||
#define MAGENTA_BG(x) MAGENTA_BG_S x CLEAR
|
||||
@@ -117,13 +131,14 @@ private:
|
||||
#define CYAN_BG_BOLD(x) CYAN_BG_BOLD_S x CLEAR
|
||||
|
||||
|
||||
#define LOG_EMERG(x, ...) xmrig::Log::print(xmrig::Log::EMERG, x, ##__VA_ARGS__)
|
||||
#define LOG_ALERT(x, ...) xmrig::Log::print(xmrig::Log::ALERT, x, ##__VA_ARGS__)
|
||||
#define LOG_CRIT(x, ...) xmrig::Log::print(xmrig::Log::CRIT, x, ##__VA_ARGS__)
|
||||
#define LOG_ERR(x, ...) xmrig::Log::print(xmrig::Log::ERR, x, ##__VA_ARGS__)
|
||||
#define LOG_WARN(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
||||
#define LOG_NOTICE(x, ...) xmrig::Log::print(xmrig::Log::NOTICE, x, ##__VA_ARGS__)
|
||||
#define LOG_INFO(x, ...) xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__)
|
||||
#define LOG_EMERG(x, ...) xmrig::Log::print(xmrig::Log::EMERG, x, ##__VA_ARGS__)
|
||||
#define LOG_ALERT(x, ...) xmrig::Log::print(xmrig::Log::ALERT, x, ##__VA_ARGS__)
|
||||
#define LOG_CRIT(x, ...) xmrig::Log::print(xmrig::Log::CRIT, x, ##__VA_ARGS__)
|
||||
#define LOG_ERR(x, ...) xmrig::Log::print(xmrig::Log::ERR, x, ##__VA_ARGS__)
|
||||
#define LOG_WARN(x, ...) xmrig::Log::print(xmrig::Log::WARNING, x, ##__VA_ARGS__)
|
||||
#define LOG_NOTICE(x, ...) xmrig::Log::print(xmrig::Log::NOTICE, x, ##__VA_ARGS__)
|
||||
#define LOG_INFO(x, ...) xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__)
|
||||
#define LOG_VERBOSE(x, ...) if (xmrig::Log::isVerbose()) { xmrig::Log::print(xmrig::Log::INFO, x, ##__VA_ARGS__); }
|
||||
|
||||
#ifdef APP_DEBUG
|
||||
# define LOG_DEBUG(x, ...) xmrig::Log::print(xmrig::Log::DEBUG, x, ##__VA_ARGS__)
|
||||
|
||||
@@ -35,14 +35,14 @@
|
||||
xmrig::ConsoleLog::ConsoleLog()
|
||||
{
|
||||
if (!isSupported()) {
|
||||
Log::colors = false;
|
||||
Log::setColors(false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_tty = new uv_tty_t;
|
||||
|
||||
if (uv_tty_init(uv_default_loop(), m_tty, 1, 0) < 0) {
|
||||
Log::colors = false;
|
||||
Log::setColors(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ xmrig::ConsoleLog::~ConsoleLog()
|
||||
|
||||
void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool colors)
|
||||
{
|
||||
if (!m_tty || Log::colors != colors) {
|
||||
if (!m_tty || Log::isColors() != colors) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/io/log/backends/FileLog.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
xmrig::FileLog::FileLog(const char *fileName)
|
||||
{
|
||||
uv_fs_t req;
|
||||
@@ -45,13 +46,12 @@ void xmrig::FileLog::print(int, const char *line, size_t, size_t size, bool colo
|
||||
return;
|
||||
}
|
||||
|
||||
# ifdef _WIN32
|
||||
uv_buf_t buf = uv_buf_init(strdup(line), static_cast<unsigned int>(size));
|
||||
# else
|
||||
uv_buf_t buf = uv_buf_init(strdup(line), size);
|
||||
# endif
|
||||
assert(strlen(line) == size);
|
||||
|
||||
uv_fs_t *req = new uv_fs_t;
|
||||
uv_buf_t buf = uv_buf_init(new char[size], size);
|
||||
memcpy(buf.base, line, size);
|
||||
|
||||
auto req = new uv_fs_t;
|
||||
req->data = buf.base;
|
||||
|
||||
uv_fs_write(uv_default_loop(), req, m_file, &buf, 1, -1, FileLog::onWrite);
|
||||
|
||||
@@ -176,12 +176,8 @@ int xmrig::Base::init()
|
||||
|
||||
Platform::init(config()->userAgent());
|
||||
|
||||
# ifndef XMRIG_PROXY_PROJECT
|
||||
Platform::setProcessPriority(config()->cpu().priority());
|
||||
# endif
|
||||
|
||||
if (isBackground()) {
|
||||
Log::background = true;
|
||||
Log::setBackground(true);
|
||||
}
|
||||
else {
|
||||
Log::add(new ConsoleLog());
|
||||
|
||||
@@ -51,7 +51,6 @@ public:
|
||||
static uint32_t setTimerResolution(uint32_t resolution);
|
||||
static void init(const char *userAgent);
|
||||
static void restoreTimerResolution();
|
||||
static void setProcessPriority(int priority);
|
||||
static void setThreadPriority(int priority);
|
||||
|
||||
static inline const char *userAgent() { return m_userAgent; }
|
||||
|
||||
@@ -83,11 +83,6 @@ void xmrig::Platform::restoreTimerResolution()
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Platform::setProcessPriority(int priority)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Platform::setThreadPriority(int priority)
|
||||
{
|
||||
if (priority == -1) {
|
||||
|
||||
@@ -111,11 +111,6 @@ void xmrig::Platform::restoreTimerResolution()
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Platform::setProcessPriority(int priority)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Platform::setThreadPriority(int priority)
|
||||
{
|
||||
if (priority == -1) {
|
||||
|
||||
@@ -131,43 +131,6 @@ void xmrig::Platform::restoreTimerResolution()
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Platform::setProcessPriority(int priority)
|
||||
{
|
||||
if (priority == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD prio = IDLE_PRIORITY_CLASS;
|
||||
switch (priority)
|
||||
{
|
||||
case 1:
|
||||
prio = BELOW_NORMAL_PRIORITY_CLASS;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
prio = NORMAL_PRIORITY_CLASS;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
prio = ABOVE_NORMAL_PRIORITY_CLASS;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
prio = HIGH_PRIORITY_CLASS;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
prio = REALTIME_PRIORITY_CLASS;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SetPriorityClass(GetCurrentProcess(), prio);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Platform::setThreadPriority(int priority)
|
||||
{
|
||||
if (priority == -1) {
|
||||
|
||||
@@ -23,10 +23,18 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "base/kernel/config/BaseConfig.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/interfaces/IJsonReader.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
@@ -38,85 +46,6 @@
|
||||
# include "backend/cpu/Cpu.h"
|
||||
#endif
|
||||
|
||||
#ifdef XMRIG_AMD_PROJECT
|
||||
# if defined(__APPLE__)
|
||||
# include <OpenCL/cl.h>
|
||||
# else
|
||||
# include "3rdparty/CL/cl.h"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef XMRIG_NVIDIA_PROJECT
|
||||
# include "nvidia/cryptonight.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/kernel/config/BaseConfig.h"
|
||||
#include "base/kernel/interfaces/IJsonReader.h"
|
||||
#include "donate.h"
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/filewritestream.h"
|
||||
#include "rapidjson/prettywriter.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
xmrig::BaseConfig::BaseConfig()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BaseConfig::printVersions()
|
||||
{
|
||||
char buf[256] = { 0 };
|
||||
|
||||
# if defined(__clang__)
|
||||
snprintf(buf, sizeof buf, "clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
# elif defined(__GNUC__)
|
||||
snprintf(buf, sizeof buf, "gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
# elif defined(_MSC_VER)
|
||||
snprintf(buf, sizeof buf, "MSVC/%d", MSVC_VERSION);
|
||||
# endif
|
||||
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s"), "ABOUT", APP_NAME, APP_VERSION, buf);
|
||||
|
||||
# if defined(XMRIG_AMD_PROJECT)
|
||||
# if CL_VERSION_2_0
|
||||
const char *ocl = "2.0";
|
||||
# elif CL_VERSION_1_2
|
||||
const char *ocl = "1.2";
|
||||
# elif CL_VERSION_1_1
|
||||
const char *ocl = "1.1";
|
||||
# elif CL_VERSION_1_0
|
||||
const char *ocl = "1.0";
|
||||
# else
|
||||
const char *ocl = "0.0";
|
||||
# endif
|
||||
int length = snprintf(buf, sizeof buf, "OpenCL/%s ", ocl);
|
||||
# elif defined(XMRIG_NVIDIA_PROJECT)
|
||||
const int cudaVersion = cuda_get_runtime_version();
|
||||
int length = snprintf(buf, sizeof buf, "CUDA/%d.%d ", cudaVersion / 1000, cudaVersion % 100);
|
||||
# endif
|
||||
|
||||
std::string libs;
|
||||
|
||||
# if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||
{
|
||||
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
||||
snprintf(buf, sizeof buf, "OpenSSL/%.*s ", static_cast<int>(strchr(v, ' ') - v), v);
|
||||
libs += buf;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if defined(XMRIG_FEATURE_HWLOC)
|
||||
libs += Cpu::info()->backend();
|
||||
# endif
|
||||
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13slibuv/%s %s"), "LIBS", uv_version_string(), libs.c_str());
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||
{
|
||||
@@ -131,12 +60,13 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
||||
m_dryRun = reader.getBool("dry-run", m_dryRun);
|
||||
m_syslog = reader.getBool("syslog", m_syslog);
|
||||
m_watch = reader.getBool("watch", m_watch);
|
||||
Log::colors = reader.getBool("colors", Log::colors);
|
||||
m_logFile = reader.getString("log-file");
|
||||
m_userAgent = reader.getString("user-agent");
|
||||
m_version = reader.getUint("version");
|
||||
|
||||
Log::setColors(reader.getBool("colors", Log::isColors()));
|
||||
setPrintTime(reader.getUint("print-time", 60));
|
||||
setVerbose(reader.getValue("verbose"));
|
||||
|
||||
const rapidjson::Value &api = reader.getObject("api");
|
||||
if (api.IsObject()) {
|
||||
@@ -167,3 +97,46 @@ bool xmrig::BaseConfig::save()
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BaseConfig::printVersions()
|
||||
{
|
||||
char buf[256] = { 0 };
|
||||
|
||||
# if defined(__clang__)
|
||||
snprintf(buf, sizeof buf, "clang/%d.%d.%d", __clang_major__, __clang_minor__, __clang_patchlevel__);
|
||||
# elif defined(__GNUC__)
|
||||
snprintf(buf, sizeof buf, "gcc/%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
|
||||
# elif defined(_MSC_VER)
|
||||
snprintf(buf, sizeof buf, "MSVC/%d", MSVC_VERSION);
|
||||
# endif
|
||||
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN_BOLD("%s/%s") WHITE_BOLD(" %s"), "ABOUT", APP_NAME, APP_VERSION, buf);
|
||||
|
||||
std::string libs;
|
||||
|
||||
# if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT)
|
||||
{
|
||||
constexpr const char *v = OPENSSL_VERSION_TEXT + 8;
|
||||
snprintf(buf, sizeof buf, "OpenSSL/%.*s ", static_cast<int>(strchr(v, ' ') - v), v);
|
||||
libs += buf;
|
||||
}
|
||||
# endif
|
||||
|
||||
# if defined(XMRIG_FEATURE_HWLOC)
|
||||
libs += Cpu::info()->backend();
|
||||
# endif
|
||||
|
||||
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13slibuv/%s %s"), "LIBS", uv_version_string(), libs.c_str());
|
||||
}
|
||||
|
||||
|
||||
void xmrig::BaseConfig::setVerbose(const rapidjson::Value &value)
|
||||
{
|
||||
if (value.IsBool()) {
|
||||
Log::setVerbose(value.GetBool() ? 1 : 0);
|
||||
}
|
||||
else if (value.IsUint()) {
|
||||
Log::setVerbose(value.GetUint());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
#include "base/net/stratum/Pools.h"
|
||||
|
||||
|
||||
struct option;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
@@ -43,7 +40,7 @@ class IJsonReader;
|
||||
class BaseConfig : public IConfig
|
||||
{
|
||||
public:
|
||||
BaseConfig();
|
||||
BaseConfig() = default;
|
||||
|
||||
inline bool isAutoSave() const { return m_autoSave; }
|
||||
inline bool isBackground() const { return m_background; }
|
||||
@@ -85,6 +82,8 @@ protected:
|
||||
|
||||
private:
|
||||
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
||||
|
||||
void setVerbose(const rapidjson::Value &value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -222,6 +222,7 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
||||
case IConfig::DryRunKey: /* --dry-run */
|
||||
case IConfig::HttpEnabledKey: /* --http-enabled */
|
||||
case IConfig::DaemonKey: /* --daemon */
|
||||
case IConfig::VerboseKey: /* --verbose */
|
||||
return transformBoolean(doc, key, true);
|
||||
|
||||
case IConfig::ColorKey: /* --no-color */
|
||||
@@ -273,6 +274,9 @@ void xmrig::BaseTransform::transformBoolean(rapidjson::Document &doc, int key, b
|
||||
case IConfig::DryRunKey: /* --dry-run */
|
||||
return set(doc, "dry-run", enable);
|
||||
|
||||
case IConfig::VerboseKey: /* --verbose */
|
||||
return set(doc, "verbose", enable);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -89,8 +89,12 @@ public:
|
||||
AssemblyKey = 1015,
|
||||
RandomXInitKey = 1022,
|
||||
RandomXNumaKey = 1023,
|
||||
RandomXModeKey = 1029,
|
||||
RandomX1GbPagesKey = 1031,
|
||||
RandomXWrmsrKey = 1032,
|
||||
CPUMaxThreadsKey = 1026,
|
||||
MemoryPoolKey = 1027,
|
||||
YieldKey = 1030,
|
||||
|
||||
// xmrig amd
|
||||
OclPlatformKey = 1400,
|
||||
@@ -125,6 +129,7 @@ public:
|
||||
TlsProtocolsKey = 1114,
|
||||
AlgoExtKey = 1115,
|
||||
ProxyPasswordKey = 1116,
|
||||
LoginFileKey = 'L',
|
||||
|
||||
// xmrig nvidia
|
||||
CudaMaxThreadsKey = 1200,
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define XMRIG_ISTRATEGY_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/http/Http.h"
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "base/io/json/Json.h"
|
||||
#include "base/net/http/Http.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -41,10 +41,7 @@ static const char *kToken = "access-token";
|
||||
|
||||
|
||||
xmrig::Http::Http() :
|
||||
m_enabled(false),
|
||||
m_restricted(true),
|
||||
m_host(kLocalhost),
|
||||
m_port(0)
|
||||
m_host(kLocalhost)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class Http
|
||||
public:
|
||||
Http();
|
||||
|
||||
inline bool isAuthRequired() const { return m_restricted == false || !m_token.isNull(); }
|
||||
inline bool isAuthRequired() const { return !m_restricted || !m_token.isNull(); }
|
||||
inline bool isEnabled() const { return m_enabled; }
|
||||
inline bool isRestricted() const { return m_restricted; }
|
||||
inline const String &host() const { return m_host; }
|
||||
@@ -58,11 +58,11 @@ public:
|
||||
void setPort(int port);
|
||||
|
||||
private:
|
||||
bool m_enabled;
|
||||
bool m_restricted;
|
||||
bool m_enabled = false;
|
||||
bool m_restricted = true;
|
||||
String m_host;
|
||||
String m_token;
|
||||
uint16_t m_port;
|
||||
uint16_t m_port = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
inline static void onWrite(uv_write_t *req, int) { delete reinterpret_cast<ClientWriteBaton *>(req->data); }
|
||||
|
||||
|
||||
uv_buf_t bufs[2];
|
||||
uv_buf_t bufs[2]{};
|
||||
|
||||
private:
|
||||
std::string m_body;
|
||||
|
||||
@@ -24,27 +24,30 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "base/net/http/HttpContext.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/kernel/interfaces/IHttpListener.h"
|
||||
#include "base/net/http/HttpContext.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static http_parser_settings http_settings;
|
||||
static std::map<uint64_t, HttpContext *> storage;
|
||||
static uint64_t SEQUENCE = 0;
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
xmrig::HttpContext::HttpContext(int parser_type, IHttpListener *listener) :
|
||||
HttpData(SEQUENCE++),
|
||||
m_wasHeaderValue(false),
|
||||
m_timestamp(Chrono::steadyMSecs()),
|
||||
m_listener(listener)
|
||||
{
|
||||
storage[id()] = this;
|
||||
@@ -96,6 +99,12 @@ std::string xmrig::HttpContext::ip() const
|
||||
}
|
||||
|
||||
|
||||
uint64_t xmrig::HttpContext::elapsed() const
|
||||
{
|
||||
return Chrono::steadyMSecs() - m_timestamp;
|
||||
}
|
||||
|
||||
|
||||
void xmrig::HttpContext::close(int status)
|
||||
{
|
||||
if (status < 0 && m_listener) {
|
||||
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
|
||||
size_t parse(const char *data, size_t size);
|
||||
std::string ip() const;
|
||||
uint64_t elapsed() const;
|
||||
void close(int status = 0);
|
||||
|
||||
static HttpContext *get(uint64_t id);
|
||||
@@ -74,7 +75,8 @@ private:
|
||||
|
||||
void setHeader();
|
||||
|
||||
bool m_wasHeaderValue;
|
||||
bool m_wasHeaderValue = false;
|
||||
const uint64_t m_timestamp;
|
||||
http_parser *m_parser;
|
||||
IHttpListener *m_listener;
|
||||
std::string m_lastHeaderField;
|
||||
|
||||
@@ -38,12 +38,12 @@ namespace xmrig {
|
||||
class HttpData
|
||||
{
|
||||
public:
|
||||
inline HttpData(uint64_t id) : method(0), status(0), m_id(id) {}
|
||||
inline HttpData(uint64_t id) : m_id(id) {}
|
||||
|
||||
inline uint64_t id() const { return m_id; }
|
||||
|
||||
int method;
|
||||
int status;
|
||||
int method = 0;
|
||||
int status = 0;
|
||||
std::map<const std::string, const std::string> headers;
|
||||
std::string body;
|
||||
std::string url;
|
||||
|
||||
@@ -24,20 +24,23 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
#include "base/net/http/HttpResponse.h"
|
||||
#include "3rdparty/http-parser/http_parser.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/net/http/HttpContext.h"
|
||||
#include "base/net/http/HttpResponse.h"
|
||||
#include "base/tools/Baton.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
static const char *kCRLF = "\r\n";
|
||||
static const char *kUserAgent = "user-agent";
|
||||
|
||||
@@ -45,6 +48,8 @@ static const char *kUserAgent = "user-agent";
|
||||
class WriteBaton : public Baton<uv_write_t>
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(WriteBaton)
|
||||
|
||||
inline WriteBaton(const std::stringstream &ss, const char *data, size_t size, HttpContext *ctx) :
|
||||
m_ctx(ctx),
|
||||
m_header(ss.str())
|
||||
@@ -79,7 +84,7 @@ public:
|
||||
inline static void onWrite(uv_write_t *req, int) { delete reinterpret_cast<WriteBaton *>(req->data); }
|
||||
|
||||
|
||||
uv_buf_t bufs[2];
|
||||
uv_buf_t bufs[2]{};
|
||||
|
||||
private:
|
||||
HttpContext *m_ctx;
|
||||
@@ -98,7 +103,7 @@ xmrig::HttpResponse::HttpResponse(uint64_t id, int statusCode) :
|
||||
|
||||
bool xmrig::HttpResponse::isAlive() const
|
||||
{
|
||||
HttpContext *ctx = HttpContext::get(m_id);
|
||||
auto ctx = HttpContext::get(m_id);
|
||||
|
||||
return ctx && uv_is_writable(ctx->stream());
|
||||
}
|
||||
@@ -129,8 +134,8 @@ void xmrig::HttpResponse::end(const char *data, size_t size)
|
||||
|
||||
ss << kCRLF;
|
||||
|
||||
HttpContext *ctx = HttpContext::get(m_id);
|
||||
WriteBaton *baton = new WriteBaton(ss, data, size, ctx);
|
||||
auto ctx = HttpContext::get(m_id);
|
||||
auto baton = new WriteBaton(ss, data, size, ctx);
|
||||
|
||||
# ifndef APP_DEBUG
|
||||
if (statusCode() >= 400)
|
||||
@@ -138,13 +143,14 @@ void xmrig::HttpResponse::end(const char *data, size_t size)
|
||||
{
|
||||
const bool err = statusCode() >= 400;
|
||||
|
||||
Log::print(err ? Log::ERR : Log::INFO, CYAN("%s ") CLEAR MAGENTA_BOLD("%s") WHITE_BOLD(" %s ") CSI "1;%dm%d " CLEAR WHITE_BOLD("%zu ") BLACK_BOLD("\"%s\""),
|
||||
Log::print(err ? Log::ERR : Log::INFO, CYAN("%s ") CLEAR MAGENTA_BOLD("%s") WHITE_BOLD(" %s ") CSI "1;%dm%d " CLEAR WHITE_BOLD("%zu ") CYAN_BOLD("%" PRIu64 "ms ") BLACK_BOLD("\"%s\""),
|
||||
ctx->ip().c_str(),
|
||||
http_method_str(static_cast<http_method>(ctx->method)),
|
||||
ctx->url.c_str(),
|
||||
err ? 31 : 32,
|
||||
statusCode(),
|
||||
baton->size(),
|
||||
ctx->elapsed(),
|
||||
ctx->headers.count(kUserAgent) ? ctx->headers.at(kUserAgent).c_str() : nullptr
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ xmrig::HttpServer::~HttpServer()
|
||||
|
||||
void xmrig::HttpServer::onConnection(uv_stream_t *stream, uint16_t)
|
||||
{
|
||||
HttpContext *ctx = new HttpContext(HTTP_REQUEST, m_listener);
|
||||
auto ctx = new HttpContext(HTTP_REQUEST, m_listener);
|
||||
uv_accept(stream, ctx->stream());
|
||||
|
||||
uv_read_start(ctx->stream(),
|
||||
@@ -65,11 +65,11 @@ void xmrig::HttpServer::onConnection(uv_stream_t *stream, uint16_t)
|
||||
},
|
||||
[](uv_stream_t *tcp, ssize_t nread, const uv_buf_t *buf)
|
||||
{
|
||||
HttpContext *ctx = static_cast<HttpContext*>(tcp->data);
|
||||
auto ctx = static_cast<HttpContext*>(tcp->data);
|
||||
|
||||
if (nread >= 0) {
|
||||
const size_t size = static_cast<size_t>(nread);
|
||||
const size_t parsed = ctx->parse(buf->base, size);
|
||||
const auto size = static_cast<size_t>(nread);
|
||||
const auto parsed = ctx->parse(buf->base, size);
|
||||
|
||||
if (parsed < size) {
|
||||
ctx->close();
|
||||
|
||||
@@ -28,11 +28,12 @@
|
||||
#define XMRIG_HTTPSERVER_H
|
||||
|
||||
|
||||
typedef struct http_parser http_parser;
|
||||
typedef struct http_parser_settings http_parser_settings;
|
||||
using http_parser = struct http_parser;
|
||||
using http_parser_settings = struct http_parser_settings;
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/ITcpServerListener.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
@@ -44,6 +45,8 @@ class IHttpListener;
|
||||
class HttpServer : public ITcpServerListener
|
||||
{
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(HttpServer)
|
||||
|
||||
HttpServer(IHttpListener *listener);
|
||||
~HttpServer() override;
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ static const char *states[] = {
|
||||
|
||||
xmrig::Client::Client(int id, const char *agent, IClientListener *listener) :
|
||||
BaseClient(id, listener),
|
||||
m_agent(agent)
|
||||
m_agent(agent),
|
||||
m_sendBuf(1024)
|
||||
{
|
||||
m_key = m_storage.add(this);
|
||||
m_dns = new Dns(this);
|
||||
@@ -158,13 +159,18 @@ int64_t xmrig::Client::send(const rapidjson::Value &obj)
|
||||
obj.Accept(writer);
|
||||
|
||||
const size_t size = buffer.GetSize();
|
||||
if (size > (sizeof(m_sendBuf) - 2)) {
|
||||
LOG_ERR("[%s] send failed: \"send buffer overflow: %zu > %zu\"", url(), size, (sizeof(m_sendBuf) - 2));
|
||||
if (size > kMaxSendBufferSize) {
|
||||
LOG_ERR("[%s] send failed: \"max send buffer size exceeded: %zu\"", url(), size);
|
||||
close();
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(m_sendBuf, buffer.GetString(), size);
|
||||
if (size > (m_sendBuf.size() - 2)) {
|
||||
m_sendBuf.resize(((size + 1) / 1024 + 1) * 1024);
|
||||
}
|
||||
|
||||
memcpy(m_sendBuf.data(), buffer.GetString(), size);
|
||||
m_sendBuf[size] = '\n';
|
||||
m_sendBuf[size + 1] = '\0';
|
||||
|
||||
@@ -186,8 +192,8 @@ int64_t xmrig::Client::submit(const JobResult &result)
|
||||
const char *nonce = result.nonce;
|
||||
const char *data = result.result;
|
||||
# else
|
||||
char *nonce = m_sendBuf;
|
||||
char *data = m_sendBuf + 16;
|
||||
char *nonce = m_sendBuf.data();
|
||||
char *data = m_sendBuf.data() + 16;
|
||||
|
||||
Buffer::toHex(reinterpret_cast<const char*>(&result.nonce), 4, nonce);
|
||||
nonce[8] = '\0';
|
||||
@@ -338,6 +344,10 @@ bool xmrig::Client::isCriticalError(const char *message)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strncasecmp(message, "Invalid job id", 14) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -456,11 +466,7 @@ bool xmrig::Client::send(BIO *bio)
|
||||
|
||||
bool result = false;
|
||||
if (state() == ConnectedState && uv_is_writable(m_stream)) {
|
||||
result = uv_try_write(m_stream, &buf, 1) > 0;
|
||||
|
||||
if (!result) {
|
||||
close();
|
||||
}
|
||||
result = write(buf);
|
||||
}
|
||||
else {
|
||||
LOG_DEBUG_ERR("[%s] send failed, invalid state: %d", url(), m_state);
|
||||
@@ -501,6 +507,23 @@ bool xmrig::Client::verifyAlgorithm(const Algorithm &algorithm, const char *algo
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Client::write(const uv_buf_t &buf)
|
||||
{
|
||||
const int rc = uv_try_write(m_stream, &buf, 1);
|
||||
if (static_cast<size_t>(rc) == buf.len) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isQuiet()) {
|
||||
LOG_ERR("[%s] write error: \"%s\"", url(), uv_strerror(rc));
|
||||
}
|
||||
|
||||
close();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int xmrig::Client::resolve(const String &host)
|
||||
{
|
||||
setState(HostLookupState);
|
||||
@@ -525,11 +548,11 @@ int xmrig::Client::resolve(const String &host)
|
||||
|
||||
int64_t xmrig::Client::send(size_t size)
|
||||
{
|
||||
LOG_DEBUG("[%s] send (%d bytes): \"%.*s\"", url(), size, static_cast<int>(size) - 1, m_sendBuf);
|
||||
LOG_DEBUG("[%s] send (%d bytes): \"%.*s\"", url(), size, static_cast<int>(size) - 1, m_sendBuf.data());
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
if (isTLS()) {
|
||||
if (!m_tls->send(m_sendBuf, size)) {
|
||||
if (!m_tls->send(m_sendBuf.data(), size)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -541,10 +564,9 @@ int64_t xmrig::Client::send(size_t size)
|
||||
return -1;
|
||||
}
|
||||
|
||||
uv_buf_t buf = uv_buf_init(m_sendBuf, (unsigned int) size);
|
||||
uv_buf_t buf = uv_buf_init(m_sendBuf.data(), (unsigned int) size);
|
||||
|
||||
if (uv_try_write(m_stream, &buf, 1) < 0) {
|
||||
close();
|
||||
if (!write(buf)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -558,7 +580,7 @@ void xmrig::Client::connect(sockaddr *addr)
|
||||
{
|
||||
setState(ConnectingState);
|
||||
|
||||
uv_connect_t *req = new uv_connect_t;
|
||||
auto req = new uv_connect_t;
|
||||
req->data = m_storage.ptr(m_key);
|
||||
|
||||
m_socket = new uv_tcp_t;
|
||||
@@ -791,7 +813,7 @@ void xmrig::Client::parseResponse(int64_t id, const rapidjson::Value &result, co
|
||||
|
||||
void xmrig::Client::ping()
|
||||
{
|
||||
send(snprintf(m_sendBuf, sizeof(m_sendBuf), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId.data()));
|
||||
send(snprintf(m_sendBuf.data(), m_sendBuf.size(), "{\"id\":%" PRId64 ",\"jsonrpc\":\"2.0\",\"method\":\"keepalived\",\"params\":{\"id\":\"%s\"}}\n", m_sequence, m_rpcId.data()));
|
||||
|
||||
m_keepAlive = 0;
|
||||
}
|
||||
@@ -799,7 +821,7 @@ void xmrig::Client::ping()
|
||||
|
||||
void xmrig::Client::read(ssize_t nread)
|
||||
{
|
||||
const size_t size = static_cast<size_t>(nread);
|
||||
const auto size = static_cast<size_t>(nread);
|
||||
|
||||
if (nread > 0 && size > m_recvBuf.available()) {
|
||||
nread = UV_ENOBUFS;
|
||||
@@ -859,7 +881,7 @@ void xmrig::Client::reconnect()
|
||||
|
||||
void xmrig::Client::setState(SocketState state)
|
||||
{
|
||||
LOG_DEBUG("[%s] state: \"%s\"", url(), states[state]);
|
||||
LOG_DEBUG("[%s] state: \"%s\" -> \"%s\"", url(), states[m_state], states[state]);
|
||||
|
||||
if (m_state == state) {
|
||||
return;
|
||||
@@ -956,6 +978,12 @@ void xmrig::Client::onConnect(uv_connect_t *req, int status)
|
||||
return;
|
||||
}
|
||||
|
||||
if (client->state() == ConnectedState) {
|
||||
LOG_ERR("[%s] already connected");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
client->m_stream = static_cast<uv_stream_t*>(req->handle);
|
||||
client->m_stream->data = req->data;
|
||||
client->setState(ConnectedState);
|
||||
|
||||
@@ -60,14 +60,10 @@ class Client : public BaseClient, public IDnsListener, public ILineListener
|
||||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE_DEFAULT(Client)
|
||||
|
||||
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
||||
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
constexpr static size_t kInputBufferSize = 1024 * 16;
|
||||
# else
|
||||
constexpr static size_t kInputBufferSize = 1024 * 2;
|
||||
# endif
|
||||
constexpr static uint64_t kConnectTimeout = 20 * 1000;
|
||||
constexpr static uint64_t kResponseTimeout = 20 * 1000;
|
||||
constexpr static size_t kInputBufferSize = 1024 * 16;
|
||||
constexpr static size_t kMaxSendBufferSize = 1024 * 16;
|
||||
|
||||
Client(int id, const char *agent, IClientListener *listener);
|
||||
~Client() override;
|
||||
@@ -100,6 +96,7 @@ private:
|
||||
bool parseLogin(const rapidjson::Value &result, int *code);
|
||||
bool send(BIO *bio);
|
||||
bool verifyAlgorithm(const Algorithm &algorithm, const char *algo) const;
|
||||
bool write(const uv_buf_t &buf);
|
||||
int resolve(const String &host);
|
||||
int64_t send(size_t size);
|
||||
void connect(sockaddr *addr);
|
||||
@@ -128,11 +125,11 @@ private:
|
||||
|
||||
static inline Client *getClient(void *data) { return m_storage.get(data); }
|
||||
|
||||
char m_sendBuf[2048] = { 0 };
|
||||
const char *m_agent;
|
||||
Dns *m_dns;
|
||||
RecvBuf<kInputBufferSize> m_recvBuf;
|
||||
std::bitset<EXT_MAX> m_extensions;
|
||||
std::vector<char> m_sendBuf;
|
||||
String m_rpcId;
|
||||
Tls *m_tls = nullptr;
|
||||
uint64_t m_expire = 0;
|
||||
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
# endif
|
||||
|
||||
static inline uint32_t *nonce(uint8_t *blob) { return reinterpret_cast<uint32_t*>(blob + 39); }
|
||||
static inline uint64_t toDiff(uint64_t target) { return 0xFFFFFFFFFFFFFFFFULL / target; }
|
||||
static inline uint64_t toDiff(uint64_t target) { return target ? (0xFFFFFFFFFFFFFFFFULL / target) : 0; }
|
||||
|
||||
inline bool operator!=(const Job &other) const { return !isEqual(other); }
|
||||
inline bool operator==(const Job &other) const { return isEqual(other); }
|
||||
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
);
|
||||
|
||||
inline bool isNicehash() const { return m_flags.test(FLAG_NICEHASH); }
|
||||
inline bool isTLS() const { return m_flags.test(FLAG_TLS); }
|
||||
inline bool isTLS() const { return m_flags.test(FLAG_TLS) || m_url.isTLS(); }
|
||||
inline bool isValid() const { return m_url.isValid(); }
|
||||
inline const Algorithm &algorithm() const { return m_algorithm; }
|
||||
inline const Coin &coin() const { return m_coin; }
|
||||
|
||||
@@ -54,7 +54,7 @@ protected:
|
||||
inline const char *mode() const override { return m_client->mode(); }
|
||||
inline const char *tlsFingerprint() const override { return m_client->tlsFingerprint(); }
|
||||
inline const char *tlsVersion() const override { return m_client->tlsVersion(); }
|
||||
inline const Job &job() const override { return m_client->job(); }
|
||||
inline const Job &job() const override { return m_job; }
|
||||
inline const Pool &pool() const override { return m_client->pool(); }
|
||||
inline const String &ip() const override { return m_client->ip(); }
|
||||
inline int id() const override { return m_client->id(); }
|
||||
|
||||
@@ -60,17 +60,17 @@ void xmrig::Arguments::add(const char *arg)
|
||||
|
||||
const size_t size = strlen(arg);
|
||||
if (size > 4 && arg[0] == '-' && arg[1] == '-') {
|
||||
const char *p = strstr(arg, "=");
|
||||
const char *p = strchr(arg, '=');
|
||||
|
||||
if (p) {
|
||||
const size_t keySize = static_cast<size_t>(p - arg);
|
||||
const auto keySize = static_cast<size_t>(p - arg);
|
||||
|
||||
m_data.push_back(String(arg, keySize));
|
||||
m_data.push_back(arg + keySize + 1);
|
||||
m_data.emplace_back(arg, keySize);
|
||||
m_data.emplace_back(arg + keySize + 1);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m_data.push_back(arg);
|
||||
m_data.emplace_back(arg);
|
||||
}
|
||||
|
||||
@@ -31,10 +31,12 @@ static inline uint8_t hf_hex2bin(uint8_t c, bool &err)
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - '0';
|
||||
}
|
||||
else if (c >= 'a' && c <= 'f') {
|
||||
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
return c - 'a' + 0xA;
|
||||
}
|
||||
else if (c >= 'A' && c <= 'F') {
|
||||
|
||||
if (c >= 'A' && c <= 'F') {
|
||||
return c - 'A' + 0xA;
|
||||
}
|
||||
|
||||
@@ -77,7 +79,9 @@ xmrig::Buffer::Buffer(const char *data, size_t size)
|
||||
xmrig::Buffer::Buffer(size_t size) :
|
||||
m_size(size)
|
||||
{
|
||||
m_data = new char[size]();
|
||||
if (size > 0) {
|
||||
m_data = new char[size]();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +109,10 @@ void xmrig::Buffer::from(const char *data, size_t size)
|
||||
|
||||
xmrig::Buffer xmrig::Buffer::allocUnsafe(size_t size)
|
||||
{
|
||||
if (size == 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Buffer buf;
|
||||
buf.m_size = size;
|
||||
buf.m_data = new char[size];
|
||||
@@ -169,6 +177,13 @@ xmrig::String xmrig::Buffer::toHex() const
|
||||
|
||||
void xmrig::Buffer::copy(const char *data, size_t size)
|
||||
{
|
||||
if (size == 0) {
|
||||
m_data = nullptr;
|
||||
m_size = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_data = new char[size];
|
||||
m_size = size;
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
@@ -46,16 +46,7 @@ static const char *modeNames[] = {
|
||||
#endif
|
||||
|
||||
|
||||
xmrig::Config::Config() :
|
||||
m_algoExt(true),
|
||||
m_debug(false),
|
||||
m_verbose(false),
|
||||
m_mode(NICEHASH_MODE),
|
||||
m_reuseTimeout(0),
|
||||
m_diff(0),
|
||||
m_workersMode(Workers::RigID)
|
||||
{
|
||||
}
|
||||
xmrig::Config::Config() = default;
|
||||
|
||||
|
||||
bool xmrig::Config::isTLS() const
|
||||
@@ -78,13 +69,18 @@ const char *xmrig::Config::modeName() const
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Config::isVerbose() const
|
||||
{
|
||||
return Log::isVerbose();
|
||||
}
|
||||
|
||||
|
||||
bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
||||
{
|
||||
if (!BaseConfig::read(reader, fileName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_verbose = reader.getBool("verbose", m_verbose);
|
||||
m_debug = reader.getBool("debug", m_debug);
|
||||
m_algoExt = reader.getBool("algo-ext", m_algoExt);
|
||||
m_reuseTimeout = reader.getInt("reuse-timeout", m_reuseTimeout);
|
||||
@@ -98,7 +94,7 @@ bool xmrig::Config::read(const IJsonReader &reader, const char *fileName)
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
const rapidjson::Value &tls = reader.getObject("tls");
|
||||
if (tls.IsObject()) {
|
||||
m_tls = std::move(TlsConfig(tls));
|
||||
m_tls = TlsConfig(tls);
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -150,12 +146,12 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
doc.AddMember("background", isBackground(), allocator);
|
||||
|
||||
Value bind(kArrayType);
|
||||
for (const xmrig::BindHost &host : m_bind) {
|
||||
for (const auto &host : m_bind) {
|
||||
bind.PushBack(host.toJSON(doc), allocator);
|
||||
}
|
||||
|
||||
doc.AddMember("bind", bind, allocator);
|
||||
doc.AddMember("colors", Log::colors, allocator);
|
||||
doc.AddMember("colors", Log::isColors(), allocator);
|
||||
doc.AddMember("custom-diff", diff(), allocator);
|
||||
doc.AddMember("donate-level", m_pools.donateLevel(), allocator);
|
||||
doc.AddMember("log-file", m_logFile.toJSON(), allocator);
|
||||
@@ -177,6 +173,12 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::toggleVerbose()
|
||||
{
|
||||
Log::setVerbose(Log::isVerbose() ? 0 : 1);
|
||||
}
|
||||
|
||||
|
||||
void xmrig::Config::setCustomDiff(uint64_t diff)
|
||||
{
|
||||
if (diff >= 100 && diff < INT_MAX) {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define XMRIG_CONFIG_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
|
||||
@@ -74,27 +74,26 @@ public:
|
||||
bool isTLS() const;
|
||||
const char *modeName() const;
|
||||
|
||||
bool isVerbose() const;
|
||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
void getJSON(rapidjson::Document &doc) const override;
|
||||
void toggleVerbose();
|
||||
|
||||
inline bool hasAlgoExt() const { return isDonateOverProxy() ? m_algoExt : true; }
|
||||
inline bool isDebug() const { return m_debug; }
|
||||
inline bool isDonateOverProxy() const { return m_pools.donateLevel() == 0 || m_mode == SIMPLE_MODE; }
|
||||
inline bool isShouldSave() const { return m_upgrade && isAutoSave(); }
|
||||
inline bool isVerbose() const { return m_verbose; }
|
||||
inline const BindHosts &bind() const { return m_bind; }
|
||||
inline const String &accessLog() const { return m_accessLog; }
|
||||
inline const String &password() const { return m_password; }
|
||||
inline const xmrig::BindHosts &bind() const { return m_bind; }
|
||||
inline int mode() const { return m_mode; }
|
||||
inline int reuseTimeout() const { return m_reuseTimeout; }
|
||||
inline static IConfig *create() { return new Config(); }
|
||||
inline uint64_t diff() const { return m_diff; }
|
||||
inline void setVerbose(bool verbose) { m_verbose = verbose; }
|
||||
inline void toggleVerbose() { m_verbose = !m_verbose; }
|
||||
inline Workers::Mode workersMode() const { return m_workersMode; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
inline const xmrig::TlsConfig &tls() const { return m_tls; }
|
||||
inline const TlsConfig &tls() const { return m_tls; }
|
||||
# endif
|
||||
|
||||
private:
|
||||
@@ -103,15 +102,14 @@ private:
|
||||
void setWorkersMode(const rapidjson::Value &value);
|
||||
|
||||
BindHosts m_bind;
|
||||
bool m_algoExt;
|
||||
bool m_debug;
|
||||
bool m_verbose;
|
||||
int m_mode;
|
||||
int m_reuseTimeout;
|
||||
bool m_algoExt = true;
|
||||
bool m_debug = false;
|
||||
int m_mode = NICEHASH_MODE;
|
||||
int m_reuseTimeout = 0;
|
||||
String m_accessLog;
|
||||
String m_password;
|
||||
uint64_t m_diff;
|
||||
Workers::Mode m_workersMode;
|
||||
uint64_t m_diff = 0;
|
||||
Workers::Mode m_workersMode = Workers::RigID;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
TlsConfig m_tls;
|
||||
|
||||
@@ -37,9 +37,7 @@ static const char *kTls = "tls";
|
||||
}
|
||||
|
||||
|
||||
xmrig::ConfigTransform::ConfigTransform()
|
||||
{
|
||||
}
|
||||
xmrig::ConfigTransform::ConfigTransform() = default;
|
||||
|
||||
|
||||
void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const char *arg)
|
||||
@@ -68,7 +66,6 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
|
||||
case IConfig::ProxyPasswordKey: /* --access-password */
|
||||
return set(doc, "access-password", arg);
|
||||
|
||||
case IConfig::VerboseKey: /* --verbose */
|
||||
case IConfig::DebugKey: /* --debug */
|
||||
return transformBoolean(doc, key, true);
|
||||
|
||||
@@ -112,9 +109,6 @@ void xmrig::ConfigTransform::transform(rapidjson::Document &doc, int key, const
|
||||
void xmrig::ConfigTransform::transformBoolean(rapidjson::Document &doc, int key, bool enable)
|
||||
{
|
||||
switch (key) {
|
||||
case IConfig::VerboseKey: /* --verbose */
|
||||
return set(doc, "verbose", enable);
|
||||
|
||||
case IConfig::DebugKey: /* --debug */
|
||||
return set(doc, "debug", enable);
|
||||
|
||||
|
||||
@@ -112,6 +112,10 @@ static AlgoName const algorithm_names[] = {
|
||||
{ "RandomXL", nullptr, Algorithm::RX_LOKI },
|
||||
{ "randomx/arq", "rx/arq", Algorithm::RX_ARQ },
|
||||
{ "RandomARQ", nullptr, Algorithm::RX_ARQ },
|
||||
{ "randomx/sfx", "rx/sfx", Algorithm::RX_SFX },
|
||||
{ "RandomSFX", nullptr, Algorithm::RX_SFX },
|
||||
{ "randomx/v", "rx/v", Algorithm::RX_V },
|
||||
{ "RandomV", nullptr, Algorithm::RX_V },
|
||||
# endif
|
||||
# ifdef XMRIG_ALGO_ARGON2
|
||||
{ "argon2/chukwa", nullptr, Algorithm::AR2_CHUKWA },
|
||||
@@ -138,6 +142,8 @@ size_t xmrig::Algorithm::l2() const
|
||||
switch (m_id) {
|
||||
case RX_0:
|
||||
case RX_LOKI:
|
||||
case RX_SFX:
|
||||
case RX_V:
|
||||
return 0x40000;
|
||||
|
||||
case RX_WOW:
|
||||
@@ -157,7 +163,9 @@ size_t xmrig::Algorithm::l2() const
|
||||
|
||||
size_t xmrig::Algorithm::l3() const
|
||||
{
|
||||
# if defined(XMRIG_ALGO_RANDOMX) || defined(XMRIG_ALGO_ARGON2)
|
||||
constexpr size_t oneMiB = 0x100000;
|
||||
# endif
|
||||
|
||||
const Family f = family();
|
||||
assert(f != UNKNOWN);
|
||||
@@ -171,6 +179,8 @@ size_t xmrig::Algorithm::l3() const
|
||||
switch (m_id) {
|
||||
case RX_0:
|
||||
case RX_LOKI:
|
||||
case RX_SFX:
|
||||
case RX_V:
|
||||
return oneMiB * 2;
|
||||
|
||||
case RX_WOW:
|
||||
@@ -270,6 +280,8 @@ xmrig::Algorithm::Family xmrig::Algorithm::family(Id id)
|
||||
case RX_WOW:
|
||||
case RX_LOKI:
|
||||
case RX_ARQ:
|
||||
case RX_SFX:
|
||||
case RX_V:
|
||||
return RANDOM_X;
|
||||
# endif
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
RX_WOW, // "rx/wow" RandomWOW (Wownero).
|
||||
RX_LOKI, // "rx/loki" RandomXL (Loki).
|
||||
RX_ARQ, // "rx/arq" RandomARQ (Arqma).
|
||||
RX_SFX, // "rx/sfx" RandomSFX (Safex Cash).
|
||||
RX_V, // "rx/v" RandomV (Monerov).
|
||||
AR2_CHUKWA, // "argon2/chukwa" Argon2id (Chukwa).
|
||||
AR2_WRKZ, // "argon2/wrkz" Argon2id (WRKZ)
|
||||
MAX
|
||||
|
||||
@@ -62,7 +62,6 @@ namespace xmrig {
|
||||
|
||||
|
||||
xmrig::Miner::Miner(const TlsContext *ctx, uint16_t port) :
|
||||
m_ip(),
|
||||
m_routeId(-1),
|
||||
m_id(++nextId),
|
||||
m_loginId(0),
|
||||
@@ -102,7 +101,12 @@ xmrig::Miner::Miner(const TlsContext *ctx, uint16_t port) :
|
||||
|
||||
xmrig::Miner::~Miner()
|
||||
{
|
||||
Handle::close(m_socket);
|
||||
if (uv_is_closing(reinterpret_cast<uv_handle_t *>(m_socket))) {
|
||||
delete m_socket;
|
||||
}
|
||||
else {
|
||||
uv_close(reinterpret_cast<uv_handle_t *>(m_socket), [](uv_handle_t *handle) { delete handle; });
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
delete m_tls;
|
||||
|
||||
@@ -123,9 +123,9 @@ private:
|
||||
|
||||
static inline Miner *getMiner(void *data) { return m_storage.get(data); }
|
||||
|
||||
char m_buf[4096];
|
||||
char m_ip[46];
|
||||
char m_rpcId[37];
|
||||
char m_buf[4096]{};
|
||||
char m_ip[46]{};
|
||||
char m_rpcId[37]{};
|
||||
int32_t m_routeId;
|
||||
int64_t m_id;
|
||||
int64_t m_loginId;
|
||||
@@ -147,7 +147,7 @@ private:
|
||||
uint64_t m_tx;
|
||||
uint8_t m_fixedByte;
|
||||
uintptr_t m_key;
|
||||
uv_buf_t m_recvBuf;
|
||||
uv_buf_t m_recvBuf{};
|
||||
uv_tcp_t *m_socket;
|
||||
|
||||
static char m_sendBuf[2048];
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -49,12 +49,14 @@ xmrig::TlsConfig::TlsConfig(const rapidjson::Value &object) :
|
||||
setCiphers(object["ciphers"].GetString());
|
||||
setCipherSuites(object["ciphersuites"].GetString());
|
||||
setDH(object["dhparam"].GetString());
|
||||
|
||||
if (m_key.isNull()) {
|
||||
setKey(object["cert-key"].GetString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
xmrig::TlsConfig::~TlsConfig()
|
||||
{
|
||||
}
|
||||
xmrig::TlsConfig::~TlsConfig() = default;
|
||||
|
||||
|
||||
rapidjson::Value xmrig::TlsConfig::toJSON(rapidjson::Document &doc) const
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||
* Copyright 2018 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
#define APP_ID "xmrig-proxy"
|
||||
#define APP_NAME "xmrig-proxy"
|
||||
#define APP_DESC "XMRig Stratum proxy"
|
||||
#define APP_VERSION "4.5.0-beta"
|
||||
#define APP_VERSION "5.4.0"
|
||||
#define APP_DOMAIN "xmrig.com"
|
||||
#define APP_SITE "www.xmrig.com"
|
||||
#define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com"
|
||||
#define APP_KIND "proxy"
|
||||
|
||||
#define APP_VER_MAJOR 4
|
||||
#define APP_VER_MINOR 5
|
||||
#define APP_VER_MAJOR 5
|
||||
#define APP_VER_MINOR 4
|
||||
#define APP_VER_PATCH 0
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
Reference in New Issue
Block a user