mirror of
https://github.com/xmrig/xmrig-proxy.git
synced 2026-02-09 02:59:17 +08:00
Added command line option --api-ipv6 and similar config option to enable IPv6 support for HTTP API.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
- Added graceful reload support, pools and some other settings now can changed without proxy restart.
|
||||
- Added command line option `--no-watch` and config option `watch` to disable config file watching.
|
||||
- Added API endpoint `GET /1/config` to get current active config.
|
||||
- Added support for IPv6:
|
||||
- Added command line option `--api-ipv6` and similar config option to enable IPv6 support for HTTP API.
|
||||
- Deprecations:
|
||||
- Option `coin` now deprecated, use `algo` instead.
|
||||
- API endpoint `GET /` now deprecated, use `GET /1/summary` instead.
|
||||
|
||||
@@ -98,7 +98,7 @@ int App::exec()
|
||||
# endif
|
||||
|
||||
# ifndef XMRIG_NO_HTTPD
|
||||
m_httpd = new Httpd(m_controller->config()->apiPort(), m_controller->config()->apiToken());
|
||||
m_httpd = new Httpd(m_controller->config()->apiPort(), m_controller->config()->apiToken(), m_controller->config()->apiIPv6());
|
||||
m_httpd->start();
|
||||
# endif
|
||||
|
||||
|
||||
@@ -31,8 +31,9 @@
|
||||
#include "log/Log.h"
|
||||
|
||||
|
||||
Httpd::Httpd(int port, const char *accessToken) :
|
||||
Httpd::Httpd(int port, const char *accessToken, bool IPv6) :
|
||||
m_idle(true),
|
||||
m_IPv6(IPv6),
|
||||
m_accessToken(accessToken ? strdup(accessToken) : nullptr),
|
||||
m_port(port),
|
||||
m_daemon(nullptr)
|
||||
@@ -61,6 +62,10 @@ bool Httpd::start()
|
||||
}
|
||||
|
||||
unsigned int flags = 0;
|
||||
if (m_IPv6 && MHD_is_feature_supported(MHD_FEATURE_IPv6)) {
|
||||
flags |= MHD_USE_DUAL_STACK;
|
||||
}
|
||||
|
||||
if (MHD_is_feature_supported(MHD_FEATURE_EPOLL)) {
|
||||
flags |= MHD_USE_EPOLL_LINUX_ONLY;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ struct MHD_Response;
|
||||
class Httpd
|
||||
{
|
||||
public:
|
||||
Httpd(int port, const char *accessToken);
|
||||
Httpd(int port, const char *accessToken, bool IPv6);
|
||||
~Httpd();
|
||||
bool start();
|
||||
|
||||
@@ -52,6 +52,7 @@ private:
|
||||
static void onTimer(uv_timer_t *handle);
|
||||
|
||||
bool m_idle;
|
||||
bool m_IPv6;
|
||||
const char *m_accessToken;
|
||||
const int m_port;
|
||||
MHD_Daemon *m_daemon;
|
||||
|
||||
@@ -49,6 +49,7 @@ static const char *algo_names[] = {
|
||||
|
||||
|
||||
xmrig::Config::Config() :
|
||||
m_apiIPv6(false),
|
||||
m_background(false),
|
||||
m_colors(true),
|
||||
m_debug(false),
|
||||
@@ -121,6 +122,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc)
|
||||
api.AddMember("port", apiPort(), allocator);
|
||||
api.AddMember("access-token", apiToken() ? rapidjson::Value(rapidjson::StringRef(apiToken())).Move() : rapidjson::Value(rapidjson::kNullType).Move(), allocator);
|
||||
api.AddMember("worker-id", apiWorkerId() ? rapidjson::Value(rapidjson::StringRef(apiWorkerId())).Move() : rapidjson::Value(rapidjson::kNullType).Move(), allocator);
|
||||
api.AddMember("ipv6", apiIPv6(), allocator);
|
||||
doc.AddMember("api", api, allocator);
|
||||
|
||||
doc.AddMember("background", background(), allocator);
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
|
||||
static Config *load(int argc, char **argv, IWatcherListener *listener);
|
||||
|
||||
inline bool apiIPv6() const { return m_apiIPv6; }
|
||||
inline bool background() const { return m_background; }
|
||||
inline bool colors() const { return m_colors; }
|
||||
inline bool isDebug() const { return m_debug; }
|
||||
@@ -103,6 +104,7 @@ private:
|
||||
void setCoin(const char *coin);
|
||||
void setFileName(const char *fileName);
|
||||
|
||||
bool m_apiIPv6;
|
||||
bool m_background;
|
||||
bool m_colors;
|
||||
bool m_debug;
|
||||
|
||||
@@ -211,6 +211,7 @@ bool xmrig::ConfigLoader::parseArg(xmrig::Config *config, int key, const char *a
|
||||
case 'S': /* --syslog */
|
||||
case 1100: /* --verbose */
|
||||
case 1101: /* --debug */
|
||||
case 4003: /* --api-ipv6 */
|
||||
return parseBoolean(config, key, true);
|
||||
|
||||
case 1002: /* --no-color */
|
||||
@@ -341,6 +342,9 @@ bool xmrig::ConfigLoader::parseBoolean(xmrig::Config *config, int key, bool enab
|
||||
config->m_watch = enable;
|
||||
break;
|
||||
|
||||
case 4003: /* --api-ipv6 */
|
||||
config->m_apiIPv6 = enable;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ static char const usage[] = "\
|
||||
Usage: " APP_ID " [OPTIONS]\n\
|
||||
Options:\n\
|
||||
-b, --bind=ADDR bind to specified address, example \"0.0.0.0:3333\"\n\
|
||||
-a, --algo=ALGO cryptonight (default) or cryptonight-lite\n\
|
||||
-o, --url=URL URL of mining server\n\
|
||||
-O, --userpass=U:P username:password pair for mining server\n\
|
||||
-u, --user=USERNAME username for mining server\n\
|
||||
@@ -56,7 +57,6 @@ Options:\n\
|
||||
--custom-diff=N override pool diff\n\
|
||||
--verbose verbose output\n\
|
||||
--user-agent=AGENT set custom user-agent string for pool\n\
|
||||
--coin=COIN xmr for all cryptonight coins or aeon\n\
|
||||
--no-color disable colored output\n\
|
||||
--no-workers disable per worker statistics\n\
|
||||
--donate-level=N donate level, default 2%%\n\
|
||||
@@ -71,8 +71,9 @@ Options:\n\
|
||||
"\
|
||||
-A --access-log-file=N log all workers access to a file\n\
|
||||
--api-port=N port for the miner API\n\
|
||||
--api-access-token=T access token for API\n\
|
||||
--api-access-token=T Bearer access token for API\n\
|
||||
--api-worker-id=ID custom worker-id for API\n\
|
||||
--api-ipv6 enable IPv6 support for API\n\
|
||||
-h, --help display this help and exit\n\
|
||||
-V, --version output version information and exit\n\
|
||||
";
|
||||
@@ -87,6 +88,7 @@ static struct option const options[] = {
|
||||
{ "api-access-token", 1, nullptr, 4001 },
|
||||
{ "api-port", 1, nullptr, 4000 },
|
||||
{ "api-worker-id", 1, nullptr, 4002 },
|
||||
{ "api-ipv6", 0, nullptr, 4003 },
|
||||
{ "background", 0, nullptr, 'B' },
|
||||
{ "bind", 1, nullptr, 'b' },
|
||||
{ "coin", 1, nullptr, 1104 },
|
||||
@@ -149,6 +151,7 @@ static struct option const api_options[] = {
|
||||
{ "port", 1, nullptr, 4000 },
|
||||
{ "access-token", 1, nullptr, 4001 },
|
||||
{ "worker-id", 1, nullptr, 4002 },
|
||||
{ "ipv6", 0, nullptr, 4003 },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user