Added TLS support for API and many other TLS related changes.
This commit is contained in:
parent
92a258f142
commit
5b610e4dfe
38 changed files with 1601 additions and 178 deletions
|
@ -66,6 +66,11 @@ const char *BaseConfig::kVerbose = "verbose";
|
|||
const char *BaseConfig::kWatch = "watch";
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
const char *BaseConfig::kTls = "tls";
|
||||
#endif
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
@ -85,11 +90,15 @@ bool xmrig::BaseConfig::read(const IJsonReader &reader, const char *fileName)
|
|||
m_logFile = reader.getString(kLogFile);
|
||||
m_userAgent = reader.getString(kUserAgent);
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
m_tls = reader.getValue(kTls);
|
||||
# endif
|
||||
|
||||
Log::setColors(reader.getBool(kColors, Log::isColors()));
|
||||
setPrintTime(reader.getUint(kPrintTime, 60));
|
||||
setVerbose(reader.getValue(kVerbose));
|
||||
|
||||
const rapidjson::Value &api = reader.getObject(kApi);
|
||||
const auto &api = reader.getObject(kApi);
|
||||
if (api.IsObject()) {
|
||||
m_apiId = Json::getString(api, kApiId);
|
||||
m_apiWorkerId = Json::getString(api, kApiWorkerId);
|
||||
|
|
|
@ -31,6 +31,11 @@
|
|||
#include "base/net/stratum/Pools.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
# include "base/net/tls/TlsConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
|
@ -55,23 +60,31 @@ public:
|
|||
static const char *kVerbose;
|
||||
static const char *kWatch;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
static const char *kTls;
|
||||
# endif
|
||||
|
||||
BaseConfig() = default;
|
||||
|
||||
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 *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 const String &apiId() const { return m_apiId; }
|
||||
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
||||
inline uint32_t printTime() const { return m_printTime; }
|
||||
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 *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 const String &apiId() const { return m_apiId; }
|
||||
inline const String &apiWorkerId() const { return m_apiWorkerId; }
|
||||
inline uint32_t printTime() const { return m_printTime; }
|
||||
|
||||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||
inline const String &fileName() const override { return m_fileName; }
|
||||
inline void setFileName(const char *fileName) override { m_fileName = fileName; }
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
inline const TlsConfig &tls() const { return m_tls; }
|
||||
# endif
|
||||
|
||||
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
|
||||
inline const String &fileName() const override { return m_fileName; }
|
||||
inline void setFileName(const char *fileName) override { m_fileName = fileName; }
|
||||
|
||||
bool read(const IJsonReader &reader, const char *fileName) override;
|
||||
bool save() override;
|
||||
|
@ -94,6 +107,10 @@ protected:
|
|||
String m_userAgent;
|
||||
uint32_t m_printTime = 60;
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
TlsConfig m_tls;
|
||||
# endif
|
||||
|
||||
private:
|
||||
inline void setPrintTime(uint32_t printTime) { if (printTime <= 3600) { m_printTime = printTime; } }
|
||||
|
||||
|
|
|
@ -44,6 +44,11 @@
|
|||
#include "core/config/Config_platform.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_TLS
|
||||
# include "base/net/tls/TlsConfig.h"
|
||||
#endif
|
||||
|
||||
|
||||
void xmrig::BaseTransform::load(JsonChain &chain, Process *process, IConfigTransform &transform)
|
||||
{
|
||||
using namespace rapidjson;
|
||||
|
@ -199,6 +204,29 @@ void xmrig::BaseTransform::transform(rapidjson::Document &doc, int key, const ch
|
|||
case IConfig::UserAgentKey: /* --user-agent */
|
||||
return set(doc, BaseConfig::kUserAgent, arg);
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
case IConfig::TlsCertKey: /* --tls-cert */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kCert, arg);
|
||||
|
||||
case IConfig::TlsCertKeyKey: /* --tls-cert-key */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kCertKey, arg);
|
||||
|
||||
case IConfig::TlsDHparamKey: /* --tls-dhparam */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kDhparam, arg);
|
||||
|
||||
case IConfig::TlsCiphersKey: /* --tls-ciphers */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kCiphers, arg);
|
||||
|
||||
case IConfig::TlsCipherSuitesKey: /* --tls-ciphersuites */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kCipherSuites, arg);
|
||||
|
||||
case IConfig::TlsProtocolsKey: /* --tls-protocols */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kProtocols, arg);
|
||||
|
||||
case IConfig::TlsGenKey: /* --tls-gen */
|
||||
return set(doc, BaseConfig::kTls, TlsConfig::kGen, arg);
|
||||
# endif
|
||||
|
||||
case IConfig::RetriesKey: /* --retries */
|
||||
case IConfig::RetryPauseKey: /* --retry-pause */
|
||||
case IConfig::PrintTimeKey: /* --print-time */
|
||||
|
|
|
@ -132,6 +132,7 @@ public:
|
|||
TlsCiphersKey = 1112,
|
||||
TlsCipherSuitesKey = 1113,
|
||||
TlsProtocolsKey = 1114,
|
||||
TlsGenKey = 1117,
|
||||
AlgoExtKey = 1115,
|
||||
ProxyPasswordKey = 1116,
|
||||
LoginFileKey = 'L',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue