bool xmrig::CommonConfig::parseBoolean(int key, bool enable) { switch (key) { case BackgroundKey: /* --background */ m_background = enable; break; case SyslogKey: /* --syslog */ m_syslog = enable; break; case KeepAliveKey: /* --keepalive */ currentPool().setKeepAlive(enable ? Pool::kKeepAliveTimeout : 0); break; case TlsKey: /* --tls */ currentPool().setTLS(enable); break; # ifndef XMRIG_PROXY_PROJECT case NicehashKey: /* --nicehash */ currentPool().setNicehash(enable); break; # endif case ColorKey: /* --no-color */ m_colors = enable; break; case WatchKey: /* watch */ m_watch = enable; break; case ApiIPv6Key: /* ipv6 */ m_apiIPv6 = enable; break; case ApiRestrictedKey: /* restricted */ m_apiRestricted = enable; break; case DryRunKey: /* --dry-run */ m_dryRun = enable; break; case AutoSaveKey: m_autoSave = enable; break; default: break; } return true; }
bool xmrig::CommonConfig::parseInt(int key, int arg) { switch (key) { case RetriesKey: /* --retries */ if (arg > 0 && arg <= 1000) { m_retries = arg; } break; case RetryPauseKey: /* --retry-pause */ if (arg > 0 && arg <= 3600) { m_retryPause = arg; } break; case KeepAliveKey: /* --keepalive */ currentPool().setKeepAlive(arg); break; case VariantKey: /* --variant */ currentPool().algorithm().parseVariant(arg); break; case DonateLevelKey: /* --donate-level */ if (arg >= kMinimumDonateLevel && arg <= 99) { m_donateLevel = arg; } break; case ApiPort: /* --api-port */ if (arg > 0 && arg <= 65536) { m_apiPort = arg; } break; case PrintTimeKey: /* --print-time */ if (arg >= 0 && arg <= 3600) { m_printTime = arg; } break; default: break; } return true; }
dAutoPool* dAutoPool::init() { if (!_super::init()) return nil; dAutoPool* current = currentPool(); _parentPool = current; if (current) current->_childPool = this; else _sTopPool = this; _childPool = nil; _sCurrentPool = this; return this; }
bool xmrig::CommonConfig::parseString(int key, const char *arg) { switch (key) { case AlgorithmKey: /* --algo */ m_algorithm.parseAlgorithm(arg); break; case UserpassKey: /* --userpass */ if (!currentPool().setUserpass(arg)) { return false; } break; case UrlKey: /* --url */ fixup(); if (m_pools.size() > 1 || m_pools[0].isValid()) { Pool pool(arg); if (pool.isValid()) { m_pools.push_back(std::move(pool)); } } else { m_pools[0].parse(arg); } if (!m_pools.back().isValid()) { return false; } break; case UserKey: /* --user */ currentPool().setUser(arg); break; case PasswordKey: /* --pass */ currentPool().setPassword(arg); break; case RigIdKey: /* --rig-id */ currentPool().setRigId(arg); break; case FingerprintKey: /* --tls-fingerprint */ currentPool().setFingerprint(arg); break; case VariantKey: /* --variant */ currentPool().algorithm().parseVariant(arg); break; case LogFileKey: /* --log-file */ m_logFile = arg; break; case ApiAccessTokenKey: /* --api-access-token */ m_apiToken = arg; break; case ApiWorkerIdKey: /* --api-worker-id */ m_apiWorkerId = arg; break; case ApiIdKey: /* --api-id */ m_apiId = arg; break; case UserAgentKey: /* --user-agent */ m_userAgent = arg; break; case RetriesKey: /* --retries */ case RetryPauseKey: /* --retry-pause */ case ApiPort: /* --api-port */ case PrintTimeKey: /* --print-time */ return parseUint64(key, 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 */ return parseBoolean(key, true); case ColorKey: /* --no-color */ case WatchKey: /* --no-watch */ case ApiRestrictedKey: /* --api-no-restricted */ return parseBoolean(key, false); case DonateLevelKey: /* --donate-level */ # ifdef XMRIG_PROXY_PROJECT if (strncmp(arg, "minemonero.pro", 14) == 0) { m_donateLevel = 0; return true; } # endif return parseUint64(key, strtol(arg, nullptr, 10)); default: break; } return true; }