forked from xmrig/xmrig-proxy
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
181 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* XMRig | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -25,6 +25,8 @@ | |
#include "base/crypto/keccak.h" | ||
#include "base/io/Env.h" | ||
#include "base/io/json/Json.h" | ||
#include "base/io/log/Log.h" | ||
#include "base/io/log/Tags.h" | ||
#include "base/kernel/Base.h" | ||
#include "base/tools/Chrono.h" | ||
#include "base/tools/Cvt.h" | ||
|
@@ -91,7 +93,11 @@ xmrig::Api::Api(Base *base) : | |
xmrig::Api::~Api() | ||
{ | ||
# ifdef XMRIG_FEATURE_HTTP | ||
delete m_httpd; | ||
if (m_httpd) { | ||
m_httpd->stop(); | ||
delete m_httpd; | ||
m_httpd = nullptr; // Ensure the pointer is set to nullptr after deletion | ||
} | ||
# endif | ||
} | ||
|
||
|
@@ -109,30 +115,41 @@ void xmrig::Api::start() | |
genWorkerId(m_base->config()->apiWorkerId()); | ||
|
||
# ifdef XMRIG_FEATURE_HTTP | ||
m_httpd = new Httpd(m_base); | ||
m_httpd->start(); | ||
if (!m_httpd) { | ||
m_httpd = new Httpd(m_base); | ||
if (!m_httpd->start()) { | ||
LOG_ERR("%s " RED_BOLD("HTTP API server failed to start."), Tags::network()); | ||
|
||
delete m_httpd; // Properly handle failure to start | ||
m_httpd = nullptr; | ||
} | ||
} | ||
# endif | ||
} | ||
|
||
|
||
void xmrig::Api::stop() | ||
{ | ||
# ifdef XMRIG_FEATURE_HTTP | ||
m_httpd->stop(); | ||
if (m_httpd) { | ||
m_httpd->stop(); | ||
} | ||
# endif | ||
} | ||
|
||
|
||
void xmrig::Api::tick() | ||
{ | ||
# ifdef XMRIG_FEATURE_HTTP | ||
if (m_httpd->isBound() || !m_base->config()->http().isEnabled()) { | ||
if (!m_httpd || !m_base->config()->http().isEnabled() || m_httpd->isBound()) { | ||
return; | ||
} | ||
|
||
if (++m_ticks % 10 == 0) { | ||
m_ticks = 0; | ||
m_httpd->start(); | ||
if (m_httpd) { | ||
m_httpd->start(); | ||
} | ||
} | ||
# endif | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* XMRig | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ class Coin | |
LOZZAX, | ||
XDAG, | ||
ZEPHYR, | ||
TOWNFORGE, | ||
MAX | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* XMRig | ||
* Copyright (c) 2014-2019 heapwolf <https://github.com/heapwolf> | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -17,7 +17,6 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include "base/net/http/HttpApiResponse.h" | ||
#include "3rdparty/rapidjson/prettywriter.h" | ||
#include "3rdparty/rapidjson/stringbuffer.h" | ||
|
@@ -65,7 +64,7 @@ void xmrig::HttpApiResponse::end() | |
} | ||
} | ||
|
||
if (!m_doc.MemberCount()) { | ||
if (m_doc.IsObject() && m_doc.ObjectEmpty()) { | ||
return HttpResponse::end(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* XMRig | ||
* Copyright (c) 2019 jtgrassie <https://github.com/jtgrassie> | ||
* Copyright (c) 2018-2023 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2023 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -609,7 +609,7 @@ bool xmrig::Client::parseLogin(const rapidjson::Value &result, int *code) | |
|
||
parseExtensions(result); | ||
|
||
const bool rc = parseJob(result["job"], code); | ||
const bool rc = parseJob(Json::getObject(result, "job"), code); | ||
m_jobs = 0; | ||
|
||
return rc; | ||
|
@@ -844,7 +844,7 @@ void xmrig::Client::parseResponse(int64_t id, const rapidjson::Value &result, co | |
m_listener->onLoginSuccess(this); | ||
|
||
if (m_job.isValid()) { | ||
m_listener->onJobReceived(this, m_job, result["job"]); | ||
m_listener->onJobReceived(this, m_job, Json::getObject(result, "job")); | ||
} | ||
|
||
return; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* XMRig | ||
* Copyright (c) 2019 Howard Chu <https://github.com/hyc> | ||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* Copyright (c) 2018-2024 SChernykh <https://github.com/SChernykh> | ||
* Copyright (c) 2016-2024 XMRig <https://github.com/xmrig>, <[email protected]> | ||
* | ||
* 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 | ||
|
@@ -59,7 +59,7 @@ class Pool | |
static const char *kCoin; | ||
static const char *kDaemon; | ||
static const char *kDaemonPollInterval; | ||
static const char* kDaemonJobTimeout; | ||
static const char *kDaemonJobTimeout; | ||
static const char *kEnabled; | ||
static const char *kFingerprint; | ||
static const char *kKeepalive; | ||
|
@@ -70,11 +70,11 @@ class Pool | |
static const char *kSOCKS5; | ||
static const char *kSubmitToOrigin; | ||
static const char *kTls; | ||
static const char* kSni; | ||
static const char *kSni; | ||
static const char *kUrl; | ||
static const char *kUser; | ||
static const char* kSpendSecretKey; | ||
static const char* kDaemonZMQPort; | ||
static const char *kSpendSecretKey; | ||
static const char *kDaemonZMQPort; | ||
static const char *kNicehashHost; | ||
|
||
constexpr static int kKeepAliveTimeout = 60; | ||
|
Oops, something went wrong.