New API settings.
This commit is contained in:
parent
1e0c410eea
commit
725796a1ab
14 changed files with 474 additions and 236 deletions
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue