mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-11 05:14:40 +00:00
Merge branch 'feature-socks5' into dev
This commit is contained in:
commit
8497e9c54f
23 changed files with 391 additions and 32 deletions
|
@ -40,6 +40,8 @@ set(HEADERS_BASE
|
||||||
src/base/net/stratum/NetworkState.h
|
src/base/net/stratum/NetworkState.h
|
||||||
src/base/net/stratum/Pool.h
|
src/base/net/stratum/Pool.h
|
||||||
src/base/net/stratum/Pools.h
|
src/base/net/stratum/Pools.h
|
||||||
|
src/base/net/stratum/ProxyUrl.h
|
||||||
|
src/base/net/stratum/Socks5.h
|
||||||
src/base/net/stratum/strategies/FailoverStrategy.h
|
src/base/net/stratum/strategies/FailoverStrategy.h
|
||||||
src/base/net/stratum/strategies/SinglePoolStrategy.h
|
src/base/net/stratum/strategies/SinglePoolStrategy.h
|
||||||
src/base/net/stratum/strategies/StrategyProxy.h
|
src/base/net/stratum/strategies/StrategyProxy.h
|
||||||
|
@ -82,6 +84,8 @@ set(SOURCES_BASE
|
||||||
src/base/net/stratum/NetworkState.cpp
|
src/base/net/stratum/NetworkState.cpp
|
||||||
src/base/net/stratum/Pool.cpp
|
src/base/net/stratum/Pool.cpp
|
||||||
src/base/net/stratum/Pools.cpp
|
src/base/net/stratum/Pools.cpp
|
||||||
|
src/base/net/stratum/ProxyUrl.cpp
|
||||||
|
src/base/net/stratum/Socks5.cpp
|
||||||
src/base/net/stratum/strategies/FailoverStrategy.cpp
|
src/base/net/stratum/strategies/FailoverStrategy.cpp
|
||||||
src/base/net/stratum/strategies/SinglePoolStrategy.cpp
|
src/base/net/stratum/strategies/SinglePoolStrategy.cpp
|
||||||
src/base/net/stratum/Url.cpp
|
src/base/net/stratum/Url.cpp
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -39,6 +39,7 @@ class Algorithm;
|
||||||
class Job;
|
class Job;
|
||||||
class JobResult;
|
class JobResult;
|
||||||
class Pool;
|
class Pool;
|
||||||
|
class ProxyUrl;
|
||||||
class String;
|
class String;
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,6 +80,7 @@ public:
|
||||||
virtual void setAlgo(const Algorithm &algo) = 0;
|
virtual void setAlgo(const Algorithm &algo) = 0;
|
||||||
virtual void setEnabled(bool enabled) = 0;
|
virtual void setEnabled(bool enabled) = 0;
|
||||||
virtual void setPool(const Pool &pool) = 0;
|
virtual void setPool(const Pool &pool) = 0;
|
||||||
|
virtual void setProxy(const ProxyUrl &proxy) = 0;
|
||||||
virtual void setQuiet(bool quiet) = 0;
|
virtual void setQuiet(bool quiet) = 0;
|
||||||
virtual void setRetries(int retries) = 0;
|
virtual void setRetries(int retries) = 0;
|
||||||
virtual void setRetryPause(uint64_t ms) = 0;
|
virtual void setRetryPause(uint64_t ms) = 0;
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -35,6 +35,7 @@ namespace xmrig {
|
||||||
class Algorithm;
|
class Algorithm;
|
||||||
class IClient;
|
class IClient;
|
||||||
class JobResult;
|
class JobResult;
|
||||||
|
class ProxyUrl;
|
||||||
|
|
||||||
|
|
||||||
class IStrategy
|
class IStrategy
|
||||||
|
@ -48,6 +49,7 @@ public:
|
||||||
virtual void connect() = 0;
|
virtual void connect() = 0;
|
||||||
virtual void resume() = 0;
|
virtual void resume() = 0;
|
||||||
virtual void setAlgo(const Algorithm &algo) = 0;
|
virtual void setAlgo(const Algorithm &algo) = 0;
|
||||||
|
virtual void setProxy(const ProxyUrl &proxy) = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
virtual void tick(uint64_t now) = 0;
|
virtual void tick(uint64_t now) = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -56,6 +56,7 @@ protected:
|
||||||
inline int64_t sequence() const override { return m_sequence; }
|
inline int64_t sequence() const override { return m_sequence; }
|
||||||
inline void setAlgo(const Algorithm &algo) override { m_pool.setAlgo(algo); }
|
inline void setAlgo(const Algorithm &algo) override { m_pool.setAlgo(algo); }
|
||||||
inline void setEnabled(bool enabled) override { m_enabled = enabled; }
|
inline void setEnabled(bool enabled) override { m_enabled = enabled; }
|
||||||
|
inline void setProxy(const ProxyUrl &proxy) override { m_pool.setProxy(proxy); }
|
||||||
inline void setQuiet(bool quiet) override { m_quiet = quiet; }
|
inline void setQuiet(bool quiet) override { m_quiet = quiet; }
|
||||||
inline void setRetries(int retries) override { m_retries = retries; }
|
inline void setRetries(int retries) override { m_retries = retries; }
|
||||||
inline void setRetryPause(uint64_t ms) override { m_retryPause = ms; }
|
inline void setRetryPause(uint64_t ms) override { m_retryPause = ms; }
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "base/kernel/interfaces/IClientListener.h"
|
#include "base/kernel/interfaces/IClientListener.h"
|
||||||
#include "base/net/dns/Dns.h"
|
#include "base/net/dns/Dns.h"
|
||||||
#include "base/net/stratum/Client.h"
|
#include "base/net/stratum/Client.h"
|
||||||
|
#include "base/net/stratum/Socks5.h"
|
||||||
#include "base/tools/Buffer.h"
|
#include "base/tools/Buffer.h"
|
||||||
#include "base/tools/Chrono.h"
|
#include "base/tools/Chrono.h"
|
||||||
#include "net/JobResult.h"
|
#include "net/JobResult.h"
|
||||||
|
@ -235,6 +236,13 @@ int64_t xmrig::Client::submit(const JobResult &result)
|
||||||
|
|
||||||
void xmrig::Client::connect()
|
void xmrig::Client::connect()
|
||||||
{
|
{
|
||||||
|
if (m_pool.proxy().isValid()) {
|
||||||
|
m_socks5 = new Socks5(this);
|
||||||
|
resolve(m_pool.proxy().host());
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
if (m_pool.isTLS()) {
|
if (m_pool.isTLS()) {
|
||||||
m_tls = new Tls(this);
|
m_tls = new Tls(this);
|
||||||
|
@ -305,10 +313,10 @@ void xmrig::Client::onResolved(const Dns &dns, int status)
|
||||||
return reconnect();
|
return reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
const DnsRecord &record = dns.get();
|
const auto &record = dns.get();
|
||||||
m_ip = record.ip();
|
m_ip = record.ip();
|
||||||
|
|
||||||
connect(record.addr(m_pool.port()));
|
connect(record.addr(m_socks5 ? m_pool.proxy().port() : m_pool.port()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -607,6 +615,10 @@ void xmrig::Client::connect(sockaddr *addr)
|
||||||
|
|
||||||
void xmrig::Client::handshake()
|
void xmrig::Client::handshake()
|
||||||
{
|
{
|
||||||
|
if (m_socks5) {
|
||||||
|
return m_socks5->handshake();
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
if (isTLS()) {
|
if (isTLS()) {
|
||||||
m_expire = Chrono::steadyMSecs() + kResponseTimeout;
|
m_expire = Chrono::steadyMSecs() + kResponseTimeout;
|
||||||
|
@ -849,6 +861,27 @@ void xmrig::Client::read(ssize_t nread)
|
||||||
|
|
||||||
m_recvBuf.nread(size);
|
m_recvBuf.nread(size);
|
||||||
|
|
||||||
|
if (m_socks5) {
|
||||||
|
if (m_socks5->read(m_recvBuf.base(), m_recvBuf.pos())) {
|
||||||
|
m_recvBuf.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_socks5->isReady()) {
|
||||||
|
delete m_socks5;
|
||||||
|
m_socks5 = nullptr;
|
||||||
|
|
||||||
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
|
if (m_pool.isTLS() && !m_tls) {
|
||||||
|
m_tls = new Tls(this);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
|
handshake();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
# ifdef XMRIG_FEATURE_TLS
|
# ifdef XMRIG_FEATURE_TLS
|
||||||
if (isTLS()) {
|
if (isTLS()) {
|
||||||
LOG_DEBUG("[%s] TLS received (%d bytes)", url(), static_cast<int>(nread));
|
LOG_DEBUG("[%s] TLS received (%d bytes)", url(), static_cast<int>(nread));
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2019 jtgrassie <https://github.com/jtgrassie>
|
* Copyright 2019 jtgrassie <https://github.com/jtgrassie>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -88,6 +88,7 @@ protected:
|
||||||
inline void onLine(char *line, size_t size) override { parse(line, size); }
|
inline void onLine(char *line, size_t size) override { parse(line, size); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class Socks5;
|
||||||
class Tls;
|
class Tls;
|
||||||
|
|
||||||
bool close();
|
bool close();
|
||||||
|
@ -128,6 +129,7 @@ private:
|
||||||
const char *m_agent;
|
const char *m_agent;
|
||||||
Dns *m_dns;
|
Dns *m_dns;
|
||||||
RecvBuf<kInputBufferSize> m_recvBuf;
|
RecvBuf<kInputBufferSize> m_recvBuf;
|
||||||
|
Socks5 *m_socks5 = nullptr;
|
||||||
std::bitset<EXT_MAX> m_extensions;
|
std::bitset<EXT_MAX> m_extensions;
|
||||||
std::vector<char> m_sendBuf;
|
std::vector<char> m_sendBuf;
|
||||||
String m_rpcId;
|
String m_rpcId;
|
||||||
|
|
|
@ -63,6 +63,7 @@ const char *Pool::kNicehash = "nicehash";
|
||||||
const char *Pool::kPass = "pass";
|
const char *Pool::kPass = "pass";
|
||||||
const char *Pool::kRigId = "rig-id";
|
const char *Pool::kRigId = "rig-id";
|
||||||
const char *Pool::kSelfSelect = "self-select";
|
const char *Pool::kSelfSelect = "self-select";
|
||||||
|
const char *Pool::kSOCKS5 = "socks5";
|
||||||
const char *Pool::kTls = "tls";
|
const char *Pool::kTls = "tls";
|
||||||
const char *Pool::kUrl = "url";
|
const char *Pool::kUrl = "url";
|
||||||
const char *Pool::kUser = "user";
|
const char *Pool::kUser = "user";
|
||||||
|
@ -96,6 +97,7 @@ xmrig::Pool::Pool(const rapidjson::Value &object) :
|
||||||
m_algorithm = Json::getString(object, kAlgo);
|
m_algorithm = Json::getString(object, kAlgo);
|
||||||
m_coin = Json::getString(object, kCoin);
|
m_coin = Json::getString(object, kCoin);
|
||||||
m_daemon = Json::getString(object, kSelfSelect);
|
m_daemon = Json::getString(object, kSelfSelect);
|
||||||
|
m_proxy = Json::getValue(object, kSOCKS5);
|
||||||
|
|
||||||
m_flags.set(FLAG_ENABLED, Json::getBool(object, kEnabled, true));
|
m_flags.set(FLAG_ENABLED, Json::getBool(object, kEnabled, true));
|
||||||
m_flags.set(FLAG_NICEHASH, Json::getBool(object, kNicehash));
|
m_flags.set(FLAG_NICEHASH, Json::getBool(object, kNicehash));
|
||||||
|
@ -173,6 +175,7 @@ bool xmrig::Pool::isEqual(const Pool &other) const
|
||||||
&& m_user == other.m_user
|
&& m_user == other.m_user
|
||||||
&& m_pollInterval == other.m_pollInterval
|
&& m_pollInterval == other.m_pollInterval
|
||||||
&& m_daemon == other.m_daemon
|
&& m_daemon == other.m_daemon
|
||||||
|
&& m_proxy == other.m_proxy
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,10 +235,11 @@ rapidjson::Value xmrig::Pool::toJSON(rapidjson::Document &doc) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.AddMember(StringRef(kEnabled), m_flags.test(FLAG_ENABLED), allocator);
|
obj.AddMember(StringRef(kEnabled), m_flags.test(FLAG_ENABLED), allocator);
|
||||||
obj.AddMember(StringRef(kTls), isTLS(), allocator);
|
obj.AddMember(StringRef(kTls), isTLS(), allocator);
|
||||||
obj.AddMember(StringRef(kFingerprint), m_fingerprint.toJSON(), allocator);
|
obj.AddMember(StringRef(kFingerprint), m_fingerprint.toJSON(), allocator);
|
||||||
obj.AddMember(StringRef(kDaemon), m_mode == MODE_DAEMON, allocator);
|
obj.AddMember(StringRef(kDaemon), m_mode == MODE_DAEMON, allocator);
|
||||||
|
obj.AddMember(StringRef(kSOCKS5), m_proxy.toJSON(doc), allocator);
|
||||||
|
|
||||||
if (m_mode == MODE_DAEMON) {
|
if (m_mode == MODE_DAEMON) {
|
||||||
obj.AddMember(StringRef(kDaemonPollInterval), m_pollInterval, allocator);
|
obj.AddMember(StringRef(kDaemonPollInterval), m_pollInterval, allocator);
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
#include "base/net/stratum/Url.h"
|
#include "base/net/stratum/ProxyUrl.h"
|
||||||
#include "crypto/common/Coin.h"
|
#include "crypto/common/Coin.h"
|
||||||
#include "rapidjson/fwd.h"
|
#include "rapidjson/fwd.h"
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ public:
|
||||||
static const char *kPass;
|
static const char *kPass;
|
||||||
static const char *kRigId;
|
static const char *kRigId;
|
||||||
static const char *kSelfSelect;
|
static const char *kSelfSelect;
|
||||||
|
static const char *kSOCKS5;
|
||||||
static const char *kTls;
|
static const char *kTls;
|
||||||
static const char *kUrl;
|
static const char *kUrl;
|
||||||
static const char *kUser;
|
static const char *kUser;
|
||||||
|
@ -91,6 +92,7 @@ public:
|
||||||
inline bool isValid() const { return m_url.isValid(); }
|
inline bool isValid() const { return m_url.isValid(); }
|
||||||
inline const Algorithm &algorithm() const { return m_algorithm; }
|
inline const Algorithm &algorithm() const { return m_algorithm; }
|
||||||
inline const Coin &coin() const { return m_coin; }
|
inline const Coin &coin() const { return m_coin; }
|
||||||
|
inline const ProxyUrl &proxy() const { return m_proxy; }
|
||||||
inline const String &fingerprint() const { return m_fingerprint; }
|
inline const String &fingerprint() const { return m_fingerprint; }
|
||||||
inline const String &host() const { return m_url.host(); }
|
inline const String &host() const { return m_url.host(); }
|
||||||
inline const String &password() const { return !m_password.isNull() ? m_password : kDefaultPassword; }
|
inline const String &password() const { return !m_password.isNull() ? m_password : kDefaultPassword; }
|
||||||
|
@ -104,6 +106,7 @@ public:
|
||||||
inline uint64_t pollInterval() const { return m_pollInterval; }
|
inline uint64_t pollInterval() const { return m_pollInterval; }
|
||||||
inline void setAlgo(const Algorithm &algorithm) { m_algorithm = algorithm; }
|
inline void setAlgo(const Algorithm &algorithm) { m_algorithm = algorithm; }
|
||||||
inline void setPassword(const String &password) { m_password = password; }
|
inline void setPassword(const String &password) { m_password = password; }
|
||||||
|
inline void setProxy(const ProxyUrl &proxy) { m_proxy = proxy; }
|
||||||
inline void setRigId(const String &rigId) { m_rigId = rigId; }
|
inline void setRigId(const String &rigId) { m_rigId = rigId; }
|
||||||
inline void setUser(const String &user) { m_user = user; }
|
inline void setUser(const String &user) { m_user = user; }
|
||||||
|
|
||||||
|
@ -135,6 +138,7 @@ private:
|
||||||
Coin m_coin;
|
Coin m_coin;
|
||||||
int m_keepAlive = 0;
|
int m_keepAlive = 0;
|
||||||
Mode m_mode = MODE_POOL;
|
Mode m_mode = MODE_POOL;
|
||||||
|
ProxyUrl m_proxy;
|
||||||
std::bitset<FLAG_MAX> m_flags = 0;
|
std::bitset<FLAG_MAX> m_flags = 0;
|
||||||
String m_fingerprint;
|
String m_fingerprint;
|
||||||
String m_password;
|
String m_password;
|
||||||
|
|
62
src/base/net/stratum/ProxyUrl.cpp
Normal file
62
src/base/net/stratum/ProxyUrl.cpp
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 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 "base/net/stratum/ProxyUrl.h"
|
||||||
|
#include "rapidjson/document.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
static const String kLocalhost = "127.0.0.1";
|
||||||
|
|
||||||
|
} // namespace xmrig
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::ProxyUrl::ProxyUrl(const rapidjson::Value &value)
|
||||||
|
{
|
||||||
|
m_port = 0;
|
||||||
|
|
||||||
|
if (value.IsString()) {
|
||||||
|
parse(value.GetString());
|
||||||
|
}
|
||||||
|
else if (value.IsUint()) {
|
||||||
|
m_port = value.GetUint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const xmrig::String &xmrig::ProxyUrl::host() const
|
||||||
|
{
|
||||||
|
return m_host.isNull() && isValid() ? kLocalhost : m_host;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rapidjson::Value xmrig::ProxyUrl::toJSON(rapidjson::Document &doc) const
|
||||||
|
{
|
||||||
|
using namespace rapidjson;
|
||||||
|
if (!isValid()) {
|
||||||
|
return Value(kNullType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_host.isNull()) {
|
||||||
|
return m_url.toJSON(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Value(m_port);
|
||||||
|
}
|
46
src/base/net/stratum/ProxyUrl.h
Normal file
46
src/base/net/stratum/ProxyUrl.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 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_PROXYURL_H
|
||||||
|
#define XMRIG_PROXYURL_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/net/stratum/Url.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class ProxyUrl : public Url
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
inline ProxyUrl() { m_port = 0; }
|
||||||
|
|
||||||
|
ProxyUrl(const rapidjson::Value &value);
|
||||||
|
|
||||||
|
inline bool isValid() const { return m_port > 0 && (m_scheme == UNSPECIFIED || m_scheme == SOCKS5); }
|
||||||
|
|
||||||
|
const String &host() const;
|
||||||
|
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_PROXYURL_H */
|
|
@ -5,9 +5,9 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2019 jtgrassie <https://github.com/jtgrassie>
|
* Copyright 2019 jtgrassie <https://github.com/jtgrassie>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2019 jtgrassie <https://github.com/jtgrassie>
|
* Copyright 2019 jtgrassie <https://github.com/jtgrassie>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -68,6 +68,7 @@ protected:
|
||||||
inline void setAlgo(const Algorithm &algo) override { m_client->setAlgo(algo); }
|
inline void setAlgo(const Algorithm &algo) override { m_client->setAlgo(algo); }
|
||||||
inline void setEnabled(bool enabled) override { m_client->setEnabled(enabled); }
|
inline void setEnabled(bool enabled) override { m_client->setEnabled(enabled); }
|
||||||
inline void setPool(const Pool &pool) override { m_client->setPool(pool); }
|
inline void setPool(const Pool &pool) override { m_client->setPool(pool); }
|
||||||
|
inline void setProxy(const ProxyUrl &proxy) override { m_client->setProxy(proxy); }
|
||||||
inline void setQuiet(bool quiet) override { m_client->setQuiet(quiet); m_quiet = quiet; }
|
inline void setQuiet(bool quiet) override { m_client->setQuiet(quiet); m_quiet = quiet; }
|
||||||
inline void setRetries(int retries) override { m_client->setRetries(retries); m_retries = retries; }
|
inline void setRetries(int retries) override { m_client->setRetries(retries); m_retries = retries; }
|
||||||
inline void setRetryPause(uint64_t ms) override { m_client->setRetryPause(ms); m_retryPause = ms; }
|
inline void setRetryPause(uint64_t ms) override { m_client->setRetryPause(ms); m_retryPause = ms; }
|
||||||
|
|
108
src/base/net/stratum/Socks5.cpp
Normal file
108
src/base/net/stratum/Socks5.cpp
Normal file
|
@ -0,0 +1,108 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 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 "base/net/stratum/Socks5.h"
|
||||||
|
|
||||||
|
|
||||||
|
xmrig::Client::Socks5::Socks5(Client *client) :
|
||||||
|
m_client(client)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::Client::Socks5::read(const char *data, size_t size)
|
||||||
|
{
|
||||||
|
if (size < m_nextSize) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data[0] == 0x05 && data[1] == 0x00) {
|
||||||
|
if (m_state == SentInitialHandshake) {
|
||||||
|
connect();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_state = Ready;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_client->close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Client::Socks5::handshake()
|
||||||
|
{
|
||||||
|
m_nextSize = 2;
|
||||||
|
m_state = SentInitialHandshake;
|
||||||
|
|
||||||
|
char buf[3] = { 0x05, 0x01, 0x00 };
|
||||||
|
|
||||||
|
m_client->write(uv_buf_init(buf, sizeof (buf)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::Client::Socks5::isIPv4(const String &host, sockaddr_storage *addr) const
|
||||||
|
{
|
||||||
|
return uv_ip4_addr(host.data(), 0, reinterpret_cast<sockaddr_in *>(addr)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::Client::Socks5::isIPv6(const String &host, sockaddr_storage *addr) const
|
||||||
|
{
|
||||||
|
return uv_ip6_addr(host.data(), 0, reinterpret_cast<sockaddr_in6 *>(addr)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Client::Socks5::connect()
|
||||||
|
{
|
||||||
|
m_nextSize = 5;
|
||||||
|
m_state = SentFinalHandshake;
|
||||||
|
|
||||||
|
const auto &host = m_client->pool().host();
|
||||||
|
std::vector<uint8_t> buf;
|
||||||
|
sockaddr_storage addr;
|
||||||
|
|
||||||
|
if (isIPv4(host, &addr)) {
|
||||||
|
buf.resize(10);
|
||||||
|
buf[3] = 0x01;
|
||||||
|
memcpy(buf.data() + 4, &reinterpret_cast<sockaddr_in *>(&addr)->sin_addr, 4);
|
||||||
|
}
|
||||||
|
else if (isIPv6(host, &addr)) {
|
||||||
|
buf.resize(22);
|
||||||
|
buf[3] = 0x04;
|
||||||
|
memcpy(buf.data() + 4, &reinterpret_cast<sockaddr_in6 *>(&addr)->sin6_addr, 16);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buf.resize(host.size() + 7);
|
||||||
|
buf[3] = 0x03;
|
||||||
|
buf[4] = static_cast<uint8_t>(host.size());
|
||||||
|
memcpy(buf.data() + 5, host.data(), host.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
buf[0] = 0x05;
|
||||||
|
buf[1] = 0x01;
|
||||||
|
buf[2] = 0x00;
|
||||||
|
|
||||||
|
const uint16_t port = htons(m_client->pool().port());
|
||||||
|
memcpy(buf.data() + (buf.size() - sizeof(port)), &port, sizeof(port));
|
||||||
|
|
||||||
|
m_client->write(uv_buf_init(reinterpret_cast<char *>(buf.data()), buf.size()));
|
||||||
|
}
|
60
src/base/net/stratum/Socks5.h
Normal file
60
src/base/net/stratum/Socks5.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
/* XMRig
|
||||||
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 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_SOCKS5_H
|
||||||
|
#define XMRIG_SOCKS5_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/net/stratum/Client.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace xmrig {
|
||||||
|
|
||||||
|
|
||||||
|
class Client::Socks5
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Socks5(Client *client);
|
||||||
|
|
||||||
|
inline bool isReady() const { return m_state == Ready; }
|
||||||
|
|
||||||
|
bool read(const char *data, size_t size);
|
||||||
|
void handshake();
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum State {
|
||||||
|
Created,
|
||||||
|
SentInitialHandshake,
|
||||||
|
SentFinalHandshake,
|
||||||
|
Ready
|
||||||
|
};
|
||||||
|
|
||||||
|
bool isIPv4(const String &host, sockaddr_storage *addr) const;
|
||||||
|
bool isIPv6(const String &host, sockaddr_storage *addr) const;
|
||||||
|
void connect();
|
||||||
|
|
||||||
|
Client *m_client;
|
||||||
|
size_t m_nextSize = 0;
|
||||||
|
State m_state = Created;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace xmrig */
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* XMRIG_SOCKS5_H */
|
|
@ -4,10 +4,10 @@
|
||||||
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2019 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -42,6 +42,7 @@ namespace xmrig {
|
||||||
|
|
||||||
static const char kStratumTcp[] = "stratum+tcp://";
|
static const char kStratumTcp[] = "stratum+tcp://";
|
||||||
static const char kStratumSsl[] = "stratum+ssl://";
|
static const char kStratumSsl[] = "stratum+ssl://";
|
||||||
|
static const char kSOCKS5[] = "socks5://";
|
||||||
|
|
||||||
#ifdef XMRIG_FEATURE_HTTP
|
#ifdef XMRIG_FEATURE_HTTP
|
||||||
static const char kDaemonHttp[] = "daemon+http://";
|
static const char kDaemonHttp[] = "daemon+http://";
|
||||||
|
@ -97,6 +98,10 @@ bool xmrig::Url::parse(const char *url)
|
||||||
m_scheme = STRATUM;
|
m_scheme = STRATUM;
|
||||||
m_tls = true;
|
m_tls = true;
|
||||||
}
|
}
|
||||||
|
else if (strncasecmp(url, kSOCKS5, sizeof(kSOCKS5) - 1) == 0) {
|
||||||
|
m_scheme = SOCKS5;
|
||||||
|
m_tls = false;
|
||||||
|
}
|
||||||
# ifdef XMRIG_FEATURE_HTTP
|
# ifdef XMRIG_FEATURE_HTTP
|
||||||
else if (strncasecmp(url, kDaemonHttps, sizeof(kDaemonHttps) - 1) == 0) {
|
else if (strncasecmp(url, kDaemonHttps, sizeof(kDaemonHttps) - 1) == 0) {
|
||||||
m_scheme = DAEMON;
|
m_scheme = DAEMON;
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
|
||||||
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
* Copyright 2019 Howard Chu <https://github.com/hyc>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -39,7 +39,8 @@ public:
|
||||||
enum Scheme {
|
enum Scheme {
|
||||||
UNSPECIFIED,
|
UNSPECIFIED,
|
||||||
STRATUM,
|
STRATUM,
|
||||||
DAEMON
|
DAEMON,
|
||||||
|
SOCKS5
|
||||||
};
|
};
|
||||||
|
|
||||||
Url() = default;
|
Url() = default;
|
||||||
|
@ -57,9 +58,8 @@ public:
|
||||||
inline bool operator==(const Url &other) const { return isEqual(other); }
|
inline bool operator==(const Url &other) const { return isEqual(other); }
|
||||||
|
|
||||||
bool isEqual(const Url &other) const;
|
bool isEqual(const Url &other) const;
|
||||||
rapidjson::Value toJSON(rapidjson::Document &doc) const;
|
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
bool parse(const char *url);
|
bool parse(const char *url);
|
||||||
bool parseIPv6(const char *addr);
|
bool parseIPv6(const char *addr);
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,14 @@ void xmrig::FailoverStrategy::setAlgo(const Algorithm &algo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::FailoverStrategy::setProxy(const ProxyUrl &proxy)
|
||||||
|
{
|
||||||
|
for (IClient *client : m_pools) {
|
||||||
|
client->setProxy(proxy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::FailoverStrategy::stop()
|
void xmrig::FailoverStrategy::stop()
|
||||||
{
|
{
|
||||||
for (auto &pool : m_pools) {
|
for (auto &pool : m_pools) {
|
||||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
||||||
void connect() override;
|
void connect() override;
|
||||||
void resume() override;
|
void resume() override;
|
||||||
void setAlgo(const Algorithm &algo) override;
|
void setAlgo(const Algorithm &algo) override;
|
||||||
|
void setProxy(const ProxyUrl &proxy) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
void tick(uint64_t now) override;
|
void tick(uint64_t now) override;
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -75,6 +75,12 @@ void xmrig::SinglePoolStrategy::setAlgo(const Algorithm &algo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::SinglePoolStrategy::setProxy(const ProxyUrl &proxy)
|
||||||
|
{
|
||||||
|
m_client->setProxy(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::SinglePoolStrategy::stop()
|
void xmrig::SinglePoolStrategy::stop()
|
||||||
{
|
{
|
||||||
m_client->disconnect();
|
m_client->disconnect();
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
|
||||||
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
|
||||||
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
|
||||||
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
|
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||||
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -55,6 +55,7 @@ protected:
|
||||||
void connect() override;
|
void connect() override;
|
||||||
void resume() override;
|
void resume() override;
|
||||||
void setAlgo(const Algorithm &algo) override;
|
void setAlgo(const Algorithm &algo) override;
|
||||||
|
void setProxy(const ProxyUrl &proxy) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
void tick(uint64_t now) override;
|
void tick(uint64_t now) override;
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,7 @@ void xmrig::Network::setJob(IClient *client, const Job &job, bool donate)
|
||||||
|
|
||||||
if (!donate && m_donate) {
|
if (!donate && m_donate) {
|
||||||
m_donate->setAlgo(job.algorithm());
|
m_donate->setAlgo(job.algorithm());
|
||||||
|
m_donate->setProxy(client->pool().proxy());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_controller->miner()->setJob(job, donate);
|
m_controller->miner()->setJob(job, donate);
|
||||||
|
|
|
@ -125,6 +125,12 @@ void xmrig::DonateStrategy::setAlgo(const xmrig::Algorithm &algo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::DonateStrategy::setProxy(const ProxyUrl &proxy)
|
||||||
|
{
|
||||||
|
m_strategy->setProxy(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::DonateStrategy::stop()
|
void xmrig::DonateStrategy::stop()
|
||||||
{
|
{
|
||||||
m_timer->stop();
|
m_timer->stop();
|
||||||
|
@ -246,8 +252,9 @@ xmrig::IClient *xmrig::DonateStrategy::createProxy()
|
||||||
const IClient *client = strategy->client();
|
const IClient *client = strategy->client();
|
||||||
m_tls = client->hasExtension(IClient::EXT_TLS);
|
m_tls = client->hasExtension(IClient::EXT_TLS);
|
||||||
|
|
||||||
Pool pool(client->ip(), client->pool().port(), m_userId, client->pool().password(), 0, true, client->isTLS());
|
Pool pool(client->pool().proxy().isValid() ? client->pool().host() : client->ip(), client->pool().port(), m_userId, client->pool().password(), 0, true, client->isTLS());
|
||||||
pool.setAlgo(client->pool().algorithm());
|
pool.setAlgo(client->pool().algorithm());
|
||||||
|
pool.setProxy(client->pool().proxy());
|
||||||
|
|
||||||
IClient *proxy = new Client(-1, Platform::userAgent(), this);
|
IClient *proxy = new Client(-1, Platform::userAgent(), this);
|
||||||
proxy->setPool(pool);
|
proxy->setPool(pool);
|
||||||
|
|
|
@ -65,6 +65,7 @@ protected:
|
||||||
int64_t submit(const JobResult &result) override;
|
int64_t submit(const JobResult &result) override;
|
||||||
void connect() override;
|
void connect() override;
|
||||||
void setAlgo(const Algorithm &algo) override;
|
void setAlgo(const Algorithm &algo) override;
|
||||||
|
void setProxy(const ProxyUrl &proxy) override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
void tick(uint64_t now) override;
|
void tick(uint64_t now) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue