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

@ -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\
";