forked from xmrig/xmrig-proxy
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge https://github.com/xmrig/xmrig-proxy into master
- Loading branch information
Showing
18 changed files
with
235 additions
and
85 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
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
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 |
---|---|---|
|
@@ -40,6 +40,7 @@ class Coin | |
RAVEN, | ||
WOWNERO, | ||
ZEPHYR, | ||
TOWNFORGE, | ||
MAX | ||
}; | ||
|
||
|
Oops, something went wrong.