New API settings.

This commit is contained in:
XMRig 2019-03-29 02:31:56 +07:00
parent 1e0c410eea
commit 725796a1ab
14 changed files with 474 additions and 236 deletions

View file

@ -21,6 +21,7 @@ include (src/base/base.cmake)
set(HEADERS
"${HEADERS_BASE}"
"${HEADERS_BASE_HTTP}"
src/api/NetworkState.h
src/App.h
src/common/config/CommonConfig.h
@ -80,6 +81,7 @@ endif()
set(SOURCES
"${SOURCES_BASE}"
"${SOURCES_BASE_HTTP}"
src/api/NetworkState.cpp
src/App.cpp
src/common/config/CommonConfig.cpp
@ -220,14 +222,9 @@ if (WITH_HTTPD)
else()
message(FATAL_ERROR "microhttpd NOT found: use `-DWITH_HTTPD=OFF` to build without http deamon support")
endif()
add_definitions(/DXMRIG_FEATURE_HTTP)
add_definitions(/DXMRIG_FEATURE_API)
else()
set(HTTPD_SOURCES "")
set(MHD_LIBRARY "")
remove_definitions(/DXMRIG_FEATURE_HTTP)
remove_definitions(/DXMRIG_FEATURE_API)
endif()
include_directories(src)

View file

@ -104,10 +104,10 @@ int xmrig::App::exec()
# ifdef XMRIG_FEATURE_HTTP
m_httpd = new Httpd(
m_controller->config()->apiPort(),
m_controller->config()->apiToken(),
m_controller->config()->isApiIPv6(),
m_controller->config()->isApiRestricted()
m_controller->config()->http().port(),
m_controller->config()->http().token(),
false,
m_controller->config()->http().isRestricted()
);
m_httpd->start();

View file

@ -142,8 +142,8 @@ void Summary::print(xmrig::Controller *controller)
print_memory(controller->config());
print_cpu(controller->config());
print_threads(controller->config());
controller->config()->printPools();
controller->config()->printAPI();
controller->config()->pools().print();
controller->config()->http().print();
print_commands(controller->config());
}

View file

@ -166,7 +166,7 @@ void ApiRouter::genId(const char *id)
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_controller->config()->apiPort());
const uint16_t port = static_cast<uint16_t>(m_controller->config()->http().port());
uint8_t *input = new uint8_t[inSize]();
memcpy(input, &port, sizeof(uint16_t));

View file

@ -21,6 +21,7 @@ set(HEADERS_BASE
src/base/kernel/Signals.h
src/base/net/dns/Dns.h
src/base/net/dns/DnsRecord.h
src/base/net/http/Http.h
src/base/net/stratum/Client.h
src/base/net/stratum/Job.h
src/base/net/stratum/Pool.h
@ -50,6 +51,7 @@ set(SOURCES_BASE
src/base/kernel/Signals.cpp
src/base/net/dns/Dns.cpp
src/base/net/dns/DnsRecord.cpp
src/base/net/http/Http.cpp
src/base/net/stratum/Client.cpp
src/base/net/stratum/Job.cpp
src/base/net/stratum/Pool.cpp
@ -77,3 +79,24 @@ if (NOT WIN32)
set(SOURCES_SYSLOG src/base/io/log/backends/SysLog.h src/base/io/log/backends/SysLog.cpp)
endif()
endif()
if (WITH_HTTPD)
set(HEADERS_BASE_HTTP
# src/base/net/http/Http.h
)
set(SOURCES_BASE_HTTP
# src/base/net/http/Http.cpp
)
add_definitions(/DXMRIG_FEATURE_HTTP)
add_definitions(/DXMRIG_FEATURE_API)
else()
set(HEADERS_BASE_HTTP "")
set(SOURCES_BASE_HTTP "")
remove_definitions(/DXMRIG_FEATURE_HTTP)
remove_definitions(/DXMRIG_FEATURE_API)
endif()
add_definitions(/DXMRIG_DEPRECATED)

112
src/base/net/http/Http.cpp Normal file
View file

@ -0,0 +1,112 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "3rdparty/rapidjson/document.h"
#include "base/io/Json.h"
#include "base/io/log/Log.h"
#include "base/net/http/Http.h"
namespace xmrig {
static const char *kEnabled = "enabled";
static const char *kHost = "host";
static const char *kLocalhost = "127.0.0.1";
static const char *kPort = "port";
static const char *kRestricted = "restricted";
static const char *kToken = "access-token";
}
xmrig::Http::Http() :
m_enabled(false),
m_restricted(true),
m_host(kLocalhost),
m_port(0)
{
}
bool xmrig::Http::isEqual(const Http &other) const
{
return other.m_enabled == m_enabled &&
other.m_restricted == m_restricted &&
other.m_host == m_host &&
other.m_token == m_token &&
other.m_port == m_port;
}
rapidjson::Value xmrig::Http::toJSON(rapidjson::Document &doc) const
{
using namespace rapidjson;
auto &allocator = doc.GetAllocator();
Value obj(kObjectType);
obj.AddMember(StringRef(kEnabled), m_enabled, allocator);
obj.AddMember(StringRef(kHost), m_host.toJSON(), allocator);
obj.AddMember(StringRef(kPort), m_port, allocator);
obj.AddMember(StringRef(kToken), m_token.toJSON(), allocator);
obj.AddMember(StringRef(kRestricted), m_restricted, allocator);
return obj;
}
void xmrig::Http::load(const rapidjson::Value &http)
{
if (!http.IsObject()) {
return;
}
m_enabled = Json::getBool(http, kEnabled);
m_restricted = Json::getBool(http, kRestricted, true);
m_host = Json::getString(http, kHost, kLocalhost);
m_token = Json::getString(http, kToken);
setPort(Json::getInt(http, kPort));
}
void xmrig::Http::print() const
{
# ifdef XMRIG_FEATURE_API
if (!isEnabled()) {
return;
}
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") BLUE_BOLD("http://%s:%d"), "HTTP API", host().data(), port());
# endif
}
void xmrig::Http::setPort(int port)
{
if (port >= 0 && port <= 65536) {
m_port = static_cast<uint16_t>(port);
}
}

73
src/base/net/http/Http.h Normal file
View file

@ -0,0 +1,73 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_HTTP_H
#define XMRIG_HTTP_H
#include "base/tools/String.h"
namespace xmrig {
class Http
{
public:
Http();
inline bool isEnabled() const { return m_enabled; }
inline bool isRestricted() const { return m_restricted; }
inline const String &host() const { return m_host; }
inline const String &token() const { return m_token; }
inline uint16_t port() const { return m_port; }
inline void setEnabled(bool enabled) { m_enabled = enabled; }
inline void setHost(const char *host) { m_host = host; }
inline void setRestricted(bool restricted) { m_restricted = restricted; }
inline void setToken(const char *token) { m_token = token; }
inline bool operator!=(const Http &other) const { return !isEqual(other); }
inline bool operator==(const Http &other) const { return isEqual(other); }
bool isEqual(const Http &other) const;
rapidjson::Value toJSON(rapidjson::Document &doc) const;
void load(const rapidjson::Value &http);
void print() const;
void setPort(int port);
private:
bool m_enabled;
bool m_restricted;
String m_host;
String m_token;
uint16_t m_port;
};
} // namespace xmrig
#endif // XMRIG_HTTP_H

View file

@ -66,38 +66,18 @@
xmrig::CommonConfig::CommonConfig() :
m_algorithm(CRYPTONIGHT, VARIANT_AUTO),
m_adjusted(false),
m_apiIPv6(false),
m_apiRestricted(true),
m_autoSave(true),
m_background(false),
m_dryRun(false),
m_syslog(false),
m_upgrade(false),
m_watch(true),
m_apiPort(0),
m_printTime(60),
m_state(NoneState)
{
}
void xmrig::CommonConfig::printAPI()
{
# ifdef XMRIG_FEATURE_API
if (apiPort() == 0) {
return;
}
Log::print(GREEN_BOLD(" * ") WHITE_BOLD("%-13s") CYAN("%s:") CYAN_BOLD("%d"), "API BIND", isApiIPv6() ? "[::]" : "0.0.0.0", apiPort());
# endif
}
void xmrig::CommonConfig::printPools()
{
m_pools.print();
}
void xmrig::CommonConfig::printVersions()
{
char buf[256] = { 0 };
@ -228,12 +208,23 @@ bool xmrig::CommonConfig::parseBoolean(int key, bool enable)
m_watch = enable;
break;
case ApiIPv6Key: /* ipv6 */
m_apiIPv6 = enable;
# ifdef XMRIG_DEPRECATED
case ApiIPv6Key: /* --api-ipv6 */
break;
case ApiRestrictedKey: /* restricted */
m_apiRestricted = enable;
case ApiRestrictedKey: /* --api-no-restricted */
fputs("option \"--api-no-restricted\" deprecated, use \"--http-no-restricted\" instead.\n", stderr);
fflush(stdout);
m_http.setRestricted(enable);
break;
# endif
case HttpRestrictedKey: /* --http-no-restricted */
m_http.setRestricted(enable);
break;
case HttpEnabledKey: /* --http-enabled */
m_http.setEnabled(enable);
break;
case DryRunKey: /* --dry-run */
@ -289,8 +280,20 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
m_logFile = arg;
break;
# ifdef XMRIG_DEPRECATED
case ApiAccessTokenKey: /* --api-access-token */
m_apiToken = arg;
fputs("option \"--api-access-token\" deprecated, use \"--http-access-token\" instead.\n", stderr);
fflush(stdout);
m_http.setToken(arg);
break;
# endif
case HttpAccessTokenKey: /* --http-access-token */
m_http.setToken(arg);
break;
case HttpHostKey: /* --http-host */
m_http.setHost(arg);
break;
case ApiWorkerIdKey: /* --api-worker-id */
@ -307,26 +310,33 @@ bool xmrig::CommonConfig::parseString(int key, const char *arg)
case RetriesKey: /* --retries */
case RetryPauseKey: /* --retry-pause */
case ApiPort: /* --api-port */
case PrintTimeKey: /* --print-time */
return parseUint64(key, strtol(arg, nullptr, 10));
case HttpPort: /* --http-port */
# ifdef XMRIG_DEPRECATED
case ApiPort: /* --api-port */
# endif
return parseUint64(key, static_cast<uint64_t>(strtol(arg, nullptr, 10)));
case BackgroundKey: /* --background */
case SyslogKey: /* --syslog */
case KeepAliveKey: /* --keepalive */
case NicehashKey: /* --nicehash */
case TlsKey: /* --tls */
case ApiIPv6Key: /* --api-ipv6 */
case DryRunKey: /* --dry-run */
case BackgroundKey: /* --background */
case SyslogKey: /* --syslog */
case KeepAliveKey: /* --keepalive */
case NicehashKey: /* --nicehash */
case TlsKey: /* --tls */
case DryRunKey: /* --dry-run */
case HttpEnabledKey: /* --http-enabled */
return parseBoolean(key, true);
case ColorKey: /* --no-color */
case WatchKey: /* --no-watch */
case ColorKey: /* --no-color */
case WatchKey: /* --no-watch */
case HttpRestrictedKey: /* --http-no-restricted */
# ifdef XMRIG_DEPRECATED
case ApiRestrictedKey: /* --api-no-restricted */
case ApiIPv6Key: /* --api-ipv6 */
# endif
return parseBoolean(key, false);
case DonateLevelKey: /* --donate-level */
return parseUint64(key, strtol(arg, nullptr, 10));
return parseUint64(key, static_cast<uint64_t>(strtol(arg, nullptr, 10)));
default:
break;
@ -348,6 +358,19 @@ void xmrig::CommonConfig::parseJSON(const rapidjson::Document &doc)
if (pools.IsArray()) {
m_pools.load(pools);
}
# ifdef XMRIG_DEPRECATED
const rapidjson::Value &api = doc["api"];
if (api.IsObject() && api.HasMember("port")) {
m_upgrade = true;
m_http.load(api);
}
else {
m_http.load(doc["http"]);
}
# else
m_http.load(doc["http"]);
# endif
}
@ -384,10 +407,16 @@ bool xmrig::CommonConfig::parseInt(int key, int arg)
m_pools.setProxyDonate(arg);
break;
# ifdef XMRIG_DEPRECATED
case ApiPort: /* --api-port */
if (arg > 0 && arg <= 65536) {
m_apiPort = arg;
}
fputs("option \"--api-port\" deprecated, use \"--http-port\" instead.\n", stderr);
fflush(stdout);
m_http.setPort(arg);
break;
# endif
case HttpPort: /* --http-port */
m_http.setPort(arg);
break;
case PrintTimeKey: /* --print-time */

View file

@ -26,8 +26,8 @@
#define XMRIG_COMMONCONFIG_H
#include "base/net/http/Http.h"
#include "base/net/stratum/Pools.h"
#include "base/tools/String.h"
#include "common/interfaces/IConfig.h"
#include "common/xmrig.h"
@ -40,19 +40,16 @@ class CommonConfig : public IConfig
public:
CommonConfig();
inline bool isApiIPv6() const { return m_apiIPv6; }
inline bool isApiRestricted() const { return m_apiRestricted; }
inline bool isAutoSave() const { return m_autoSave; }
inline bool isBackground() const { return m_background; }
inline bool isDryRun() const { return m_dryRun; }
inline bool isSyslog() const { return m_syslog; }
inline const char *apiId() const { return m_apiId.data(); }
inline const char *apiToken() const { return m_apiToken.data(); }
inline const char *apiWorkerId() const { return m_apiWorkerId.data(); }
inline const String &apiId() const { return m_apiId; }
inline const String &apiWorkerId() const { return m_apiWorkerId; }
inline const char *logFile() const { return m_logFile.data(); }
inline const char *userAgent() const { return m_userAgent.data(); }
inline const Http &http() const { return m_http; }
inline const Pools &pools() const { return m_pools; }
inline int apiPort() const { return m_apiPort; }
inline int printTime() const { return m_printTime; }
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
@ -61,8 +58,6 @@ public:
bool save() override;
void printAPI();
void printPools();
void printVersions();
protected:
@ -81,19 +76,17 @@ protected:
Algorithm m_algorithm;
bool m_adjusted;
bool m_apiIPv6;
bool m_apiRestricted;
bool m_autoSave;
bool m_background;
bool m_dryRun;
bool m_syslog;
bool m_upgrade;
bool m_watch;
int m_apiPort;
Http m_http;
int m_printTime;
Pools m_pools;
State m_state;
String m_apiId;
String m_apiToken;
String m_apiWorkerId;
String m_fileName;
String m_logFile;

View file

@ -41,94 +41,102 @@ class IConfig
public:
enum Keys {
// common
AlgorithmKey = 'a',
ApiAccessTokenKey = 4001,
ApiIPv6Key = 4003,
ApiPort = 4000,
ApiRestrictedKey = 4004,
ApiWorkerIdKey = 4002,
ApiIdKey = 4005,
BackgroundKey = 'B',
ColorKey = 1002,
ConfigKey = 'c',
DonateLevelKey = 1003,
KeepAliveKey = 'k',
LogFileKey = 'l',
PasswordKey = 'p',
RetriesKey = 'r',
RetryPauseKey = 'R',
RigIdKey = 1012,
SyslogKey = 'S',
UrlKey = 'o',
UserAgentKey = 1008,
UserKey = 'u',
UserpassKey = 'O',
VariantKey = 1010,
VerboseKey = 1100,
WatchKey = 1105,
TlsKey = 1013,
FingerprintKey = 1014,
AutoSaveKey = 1016,
ProxyDonateKey = 1017,
AlgorithmKey = 'a',
ApiWorkerIdKey = 4002,
ApiIdKey = 4005,
HttpPort = 4100,
HttpAccessTokenKey = 4101,
HttpRestrictedKey = 4104,
HttpEnabledKey = 4106,
HttpHostKey = 4107,
BackgroundKey = 'B',
ColorKey = 1002,
ConfigKey = 'c',
DonateLevelKey = 1003,
KeepAliveKey = 'k',
LogFileKey = 'l',
PasswordKey = 'p',
RetriesKey = 'r',
RetryPauseKey = 'R',
RigIdKey = 1012,
SyslogKey = 'S',
UrlKey = 'o',
UserAgentKey = 1008,
UserKey = 'u',
UserpassKey = 'O',
VariantKey = 1010,
VerboseKey = 1100,
WatchKey = 1105,
TlsKey = 1013,
FingerprintKey = 1014,
AutoSaveKey = 1016,
ProxyDonateKey = 1017,
# ifdef XMRIG_DEPRECATED
ApiPort = 4000,
ApiAccessTokenKey = 4001,
ApiIPv6Key = 4003,
ApiRestrictedKey = 4004,
# endif
// xmrig common
CPUPriorityKey = 1021,
NicehashKey = 1006,
PrintTimeKey = 1007,
CPUPriorityKey = 1021,
NicehashKey = 1006,
PrintTimeKey = 1007,
// xmrig cpu
AVKey = 'v',
CPUAffinityKey = 1020,
DryRunKey = 5000,
HugePagesKey = 1009,
MaxCPUUsageKey = 1004,
SafeKey = 1005,
ThreadsKey = 't',
HardwareAESKey = 1011,
AssemblyKey = 1015,
AVKey = 'v',
CPUAffinityKey = 1020,
DryRunKey = 5000,
HugePagesKey = 1009,
MaxCPUUsageKey = 1004,
SafeKey = 1005,
ThreadsKey = 't',
HardwareAESKey = 1011,
AssemblyKey = 1015,
// xmrig amd
OclPlatformKey = 1400,
OclAffinityKey = 1401,
OclDevicesKey = 1402,
OclLaunchKey = 1403,
OclCacheKey = 1404,
OclPrintKey = 1405,
OclLoaderKey = 1406,
OclSridedIndexKey = 1407,
OclMemChunkKey = 1408,
OclUnrollKey = 1409,
OclCompModeKey = 1410,
OclPlatformKey = 1400,
OclAffinityKey = 1401,
OclDevicesKey = 1402,
OclLaunchKey = 1403,
OclCacheKey = 1404,
OclPrintKey = 1405,
OclLoaderKey = 1406,
OclSridedIndexKey = 1407,
OclMemChunkKey = 1408,
OclUnrollKey = 1409,
OclCompModeKey = 1410,
// xmrig-proxy
AccessLogFileKey = 'A',
BindKey = 'b',
CoinKey = 1104,
CustomDiffKey = 1102,
DebugKey = 1101,
ModeKey = 'm',
PoolCoinKey = 'C',
ReuseTimeoutKey = 1106,
WorkersKey = 1103,
WorkersAdvKey = 1107,
TlsBindKey = 1108,
TlsCertKey = 1109,
TlsCertKeyKey = 1110,
TlsDHparamKey = 1111,
TlsCiphersKey = 1112,
TlsCipherSuitesKey = 1113,
TlsProtocolsKey = 1114,
AlgoExtKey = 1115,
ProxyPasswordKey = 1116,
AccessLogFileKey = 'A',
BindKey = 'b',
CoinKey = 1104,
CustomDiffKey = 1102,
DebugKey = 1101,
ModeKey = 'm',
PoolCoinKey = 'C',
ReuseTimeoutKey = 1106,
WorkersKey = 1103,
WorkersAdvKey = 1107,
TlsBindKey = 1108,
TlsCertKey = 1109,
TlsCertKeyKey = 1110,
TlsDHparamKey = 1111,
TlsCiphersKey = 1112,
TlsCipherSuitesKey = 1113,
TlsProtocolsKey = 1114,
AlgoExtKey = 1115,
ProxyPasswordKey = 1116,
// xmrig nvidia
CudaMaxThreadsKey = 1200,
CudaBFactorKey = 1201,
CudaBSleepKey = 1202,
CudaDevicesKey = 1203,
CudaLaunchKey = 1204,
CudaAffinityKey = 1205,
CudaMaxUsageKey = 1206,
CudaMaxThreadsKey = 1200,
CudaBFactorKey = 1201,
CudaBSleepKey = 1202,
CudaDevicesKey = 1203,
CudaLaunchKey = 1204,
CudaAffinityKey = 1205,
CudaMaxUsageKey = 1206,
};
virtual ~IConfig() = default;

View file

@ -73,13 +73,10 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
doc.AddMember("algo", StringRef(algorithm().name()), allocator);
Value api(kObjectType);
api.AddMember("port", apiPort(), allocator);
api.AddMember("access-token", apiToken() ? Value(StringRef(apiToken())).Move() : Value(kNullType).Move(), allocator);
api.AddMember("id", apiId() ? Value(StringRef(apiId())).Move() : Value(kNullType).Move(), allocator);
api.AddMember("worker-id", apiWorkerId() ? Value(StringRef(apiWorkerId())).Move() : Value(kNullType).Move(), allocator);
api.AddMember("ipv6", isApiIPv6(), allocator);
api.AddMember("restricted", isApiRestricted(), allocator);
api.AddMember("id", m_apiId.toJSON(), allocator);
api.AddMember("worker-id", m_apiWorkerId.toJSON(), allocator);
doc.AddMember("api", api, allocator);
doc.AddMember("http", m_http.toJSON(doc), allocator);
# ifndef XMRIG_NO_ASM
doc.AddMember("asm", Asm::toJSON(m_assembly), allocator);
@ -269,7 +266,7 @@ bool xmrig::Config::parseUint64(int key, uint64_t arg)
switch (key) {
case CPUAffinityKey: /* --cpu-affinity */
if (arg) {
m_threads.mask = arg;
m_threads.mask = static_cast<int64_t>(arg);
}
break;

View file

@ -75,7 +75,7 @@ public:
inline AlgoVariant algoVariant() const { return m_algoVariant; }
inline Assembly assembly() const { return m_assembly; }
inline bool isHugePages() const { return m_hugePages; }
inline bool isShouldSave() const { return m_shouldSave && isAutoSave(); }
inline bool isShouldSave() const { return (m_shouldSave || m_upgrade) && isAutoSave(); }
inline const std::vector<IThread *> &threads() const { return m_threads.list; }
inline int priority() const { return m_priority; }
inline int threadsCount() const { return m_threads.list.size(); }

View file

@ -44,45 +44,54 @@ static char const short_options[] = "a:c:kBp:Px:r:R:s:t:T:o:u:O:v:l:S";
static struct option const options[] = {
{ "algo", 1, nullptr, IConfig::AlgorithmKey },
{ "api-access-token", 1, nullptr, IConfig::ApiAccessTokenKey },
{ "api-port", 1, nullptr, IConfig::ApiPort },
{ "api-worker-id", 1, nullptr, IConfig::ApiWorkerIdKey },
{ "api-id", 1, nullptr, IConfig::ApiIdKey },
{ "api-ipv6", 0, nullptr, IConfig::ApiIPv6Key },
{ "api-no-restricted", 0, nullptr, IConfig::ApiRestrictedKey },
{ "av", 1, nullptr, IConfig::AVKey },
{ "background", 0, nullptr, IConfig::BackgroundKey },
{ "config", 1, nullptr, IConfig::ConfigKey },
{ "cpu-affinity", 1, nullptr, IConfig::CPUAffinityKey },
{ "cpu-priority", 1, nullptr, IConfig::CPUPriorityKey },
{ "donate-level", 1, nullptr, IConfig::DonateLevelKey },
{ "donate-over-proxy", 1, nullptr, IConfig::ProxyDonateKey },
{ "dry-run", 0, nullptr, IConfig::DryRunKey },
{ "keepalive", 0, nullptr, IConfig::KeepAliveKey },
{ "log-file", 1, nullptr, IConfig::LogFileKey },
{ "max-cpu-usage", 1, nullptr, IConfig::MaxCPUUsageKey },
{ "nicehash", 0, nullptr, IConfig::NicehashKey },
{ "no-color", 0, nullptr, IConfig::ColorKey },
{ "no-watch", 0, nullptr, IConfig::WatchKey },
{ "no-huge-pages", 0, nullptr, IConfig::HugePagesKey },
{ "variant", 1, nullptr, IConfig::VariantKey },
{ "pass", 1, nullptr, IConfig::PasswordKey },
{ "print-time", 1, nullptr, IConfig::PrintTimeKey },
{ "retries", 1, nullptr, IConfig::RetriesKey },
{ "retry-pause", 1, nullptr, IConfig::RetryPauseKey },
{ "safe", 0, nullptr, IConfig::SafeKey },
{ "syslog", 0, nullptr, IConfig::SyslogKey },
{ "threads", 1, nullptr, IConfig::ThreadsKey },
{ "url", 1, nullptr, IConfig::UrlKey },
{ "user", 1, nullptr, IConfig::UserKey },
{ "user-agent", 1, nullptr, IConfig::UserAgentKey },
{ "userpass", 1, nullptr, IConfig::UserpassKey },
{ "rig-id", 1, nullptr, IConfig::RigIdKey },
{ "tls", 0, nullptr, IConfig::TlsKey },
{ "tls-fingerprint", 1, nullptr, IConfig::FingerprintKey },
{ "asm", 1, nullptr, IConfig::AssemblyKey },
{ nullptr, 0, nullptr, 0 }
{ "algo", 1, nullptr, IConfig::AlgorithmKey },
{ "api-worker-id", 1, nullptr, IConfig::ApiWorkerIdKey },
{ "api-id", 1, nullptr, IConfig::ApiIdKey },
{ "http-enabled", 0, nullptr, IConfig::HttpEnabledKey },
{ "http-host", 1, nullptr, IConfig::HttpHostKey },
{ "http-access-token", 1, nullptr, IConfig::HttpAccessTokenKey },
{ "http-port", 1, nullptr, IConfig::HttpPort },
{ "http-no-restricted", 0, nullptr, IConfig::HttpRestrictedKey },
{ "av", 1, nullptr, IConfig::AVKey },
{ "background", 0, nullptr, IConfig::BackgroundKey },
{ "config", 1, nullptr, IConfig::ConfigKey },
{ "cpu-affinity", 1, nullptr, IConfig::CPUAffinityKey },
{ "cpu-priority", 1, nullptr, IConfig::CPUPriorityKey },
{ "donate-level", 1, nullptr, IConfig::DonateLevelKey },
{ "donate-over-proxy", 1, nullptr, IConfig::ProxyDonateKey },
{ "dry-run", 0, nullptr, IConfig::DryRunKey },
{ "keepalive", 0, nullptr, IConfig::KeepAliveKey },
{ "log-file", 1, nullptr, IConfig::LogFileKey },
{ "max-cpu-usage", 1, nullptr, IConfig::MaxCPUUsageKey },
{ "nicehash", 0, nullptr, IConfig::NicehashKey },
{ "no-color", 0, nullptr, IConfig::ColorKey },
{ "no-watch", 0, nullptr, IConfig::WatchKey },
{ "no-huge-pages", 0, nullptr, IConfig::HugePagesKey },
{ "variant", 1, nullptr, IConfig::VariantKey },
{ "pass", 1, nullptr, IConfig::PasswordKey },
{ "print-time", 1, nullptr, IConfig::PrintTimeKey },
{ "retries", 1, nullptr, IConfig::RetriesKey },
{ "retry-pause", 1, nullptr, IConfig::RetryPauseKey },
{ "safe", 0, nullptr, IConfig::SafeKey },
{ "syslog", 0, nullptr, IConfig::SyslogKey },
{ "threads", 1, nullptr, IConfig::ThreadsKey },
{ "url", 1, nullptr, IConfig::UrlKey },
{ "user", 1, nullptr, IConfig::UserKey },
{ "user-agent", 1, nullptr, IConfig::UserAgentKey },
{ "userpass", 1, nullptr, IConfig::UserpassKey },
{ "rig-id", 1, nullptr, IConfig::RigIdKey },
{ "tls", 0, nullptr, IConfig::TlsKey },
{ "tls-fingerprint", 1, nullptr, IConfig::FingerprintKey },
{ "asm", 1, nullptr, IConfig::AssemblyKey },
# ifdef XMRIG_DEPRECATED
{ "api-port", 1, nullptr, IConfig::ApiPort },
{ "api-access-token", 1, nullptr, IConfig::ApiAccessTokenKey },
{ "api-no-restricted", 0, nullptr, IConfig::ApiRestrictedKey },
{ "api-ipv6", 0, nullptr, IConfig::ApiIPv6Key },
# endif
{ nullptr, 0, nullptr, 0 }
};
@ -115,11 +124,7 @@ static struct option const config_options[] = {
static struct option const api_options[] = {
{ "port", 1, nullptr, IConfig::ApiPort },
{ "access-token", 1, nullptr, IConfig::ApiAccessTokenKey },
{ "worker-id", 1, nullptr, IConfig::ApiWorkerIdKey },
{ "ipv6", 0, nullptr, IConfig::ApiIPv6Key },
{ "restricted", 0, nullptr, IConfig::ApiRestrictedKey },
{ "id", 1, nullptr, IConfig::ApiIdKey },
{ nullptr, 0, nullptr, 0 }
};

View file

@ -35,58 +35,59 @@ namespace xmrig {
static char const usage[] = "\
Usage: " APP_ID " [OPTIONS]\n\
Options:\n\
-a, --algo=ALGO specify the algorithm to use\n\
cryptonight\n"
-a, --algo=ALGO specify the algorithm to use\n\
cryptonight\n"
#ifndef XMRIG_NO_AEON
"\
cryptonight-lite\n"
cryptonight-lite\n"
#endif
#ifndef XMRIG_NO_SUMO
"\
cryptonight-heavy\n"
cryptonight-heavy\n"
#endif
"\
-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\
-p, --pass=PASSWORD password for mining server\n\
--rig-id=ID rig identifier for pool-side statistics (needs pool support)\n\
-t, --threads=N number of miner threads\n\
-v, --av=N algorithm variation, 0 auto select\n\
-k, --keepalive send keepalived packet for prevent timeout (needs pool support)\n\
--nicehash enable nicehash.com support\n\
--tls enable SSL/TLS support (needs pool support)\n\
--tls-fingerprint=F pool TLS certificate fingerprint, if set enable strict certificate pinning\n\
-r, --retries=N number of times to retry before switch to backup server (default: 5)\n\
-R, --retry-pause=N time to pause between retries (default: 5)\n\
--cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1\n\
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
--no-huge-pages disable huge pages support\n\
--no-color disable colored output\n\
--variant algorithm PoW variant\n\
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
--user-agent set custom user-agent string for pool\n\
-B, --background run the miner in the background\n\
-c, --config=FILE load a JSON-format configuration file\n\
-l, --log-file=FILE log all output to a file\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\
-p, --pass=PASSWORD password for mining server\n\
--rig-id=ID rig identifier for pool-side statistics (needs pool support)\n\
-t, --threads=N number of miner threads\n\
-v, --av=N algorithm variation, 0 auto select\n\
-k, --keepalive send keepalived packet for prevent timeout (needs pool support)\n\
--nicehash enable nicehash.com support\n\
--tls enable SSL/TLS support (needs pool support)\n\
--tls-fingerprint=F pool TLS certificate fingerprint, if set enable strict certificate pinning\n\
-r, --retries=N number of times to retry before switch to backup server (default: 5)\n\
-R, --retry-pause=N time to pause between retries (default: 5)\n\
--cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1\n\
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)\n\
--no-huge-pages disable huge pages support\n\
--no-color disable colored output\n\
--variant algorithm PoW variant\n\
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
--user-agent set custom user-agent string for pool\n\
-B, --background run the miner in the background\n\
-c, --config=FILE load a JSON-format configuration file\n\
-l, --log-file=FILE log all output to a file\n"
# ifdef HAVE_SYSLOG_H
"\
-S, --syslog use system log for output messages\n"
-S, --syslog use system log for output messages\n"
# endif
"\
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)\n\
--safe safe adjust threads and av settings for current CPU\n\
--asm=ASM ASM code for cn/2, possible values: auto, none, intel, ryzen, bulldozer.\n\
--print-time=N print hashrate report every N seconds\n\
--api-port=N port for the miner API\n\
--api-access-token=T access token for API\n\
--api-worker-id=ID custom worker-id for API\n\
--api-id=ID custom instance ID for API\n\
--api-ipv6 enable IPv6 support for API\n\
--api-no-restricted enable full remote access (only if API token set)\n\
--dry-run test configuration and exit\n\
-h, --help display this help and exit\n\
-V, --version output version information and exit\n\
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)\n\
--safe safe adjust threads and av settings for current CPU\n\
--asm=ASM ASM code for cn/2, possible values: auto, none, intel, ryzen, bulldozer.\n\
--print-time=N print hashrate report every N seconds\n\
--api-worker-id=ID custom worker-id for API\n\
--api-id=ID custom instance ID for API\n\
--http-enabled enable HTTP API\n\
--http-host=HOST bind host for HTTP API (by default 127.0.0.1)\n\
--http-port=N bind port for HTTP API\n\
--http-access-token=T access token for HTTP API\n\
--http-no-restricted enable full remote access to HTTP API (only if access token set)\n\
--dry-run test configuration and exit\n\
-h, --help display this help and exit\n\
-V, --version output version information and exit\n\
";