Merge branch 'feature-socks5' into dev
This commit is contained in:
commit
8497e9c54f
23 changed files with 391 additions and 32 deletions
|
@ -44,6 +44,7 @@
|
|||
#include "base/kernel/interfaces/IClientListener.h"
|
||||
#include "base/net/dns/Dns.h"
|
||||
#include "base/net/stratum/Client.h"
|
||||
#include "base/net/stratum/Socks5.h"
|
||||
#include "base/tools/Buffer.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "net/JobResult.h"
|
||||
|
@ -235,6 +236,13 @@ int64_t xmrig::Client::submit(const JobResult &result)
|
|||
|
||||
void xmrig::Client::connect()
|
||||
{
|
||||
if (m_pool.proxy().isValid()) {
|
||||
m_socks5 = new Socks5(this);
|
||||
resolve(m_pool.proxy().host());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
if (m_pool.isTLS()) {
|
||||
m_tls = new Tls(this);
|
||||
|
@ -305,10 +313,10 @@ void xmrig::Client::onResolved(const Dns &dns, int status)
|
|||
return reconnect();
|
||||
}
|
||||
|
||||
const DnsRecord &record = dns.get();
|
||||
const auto &record = dns.get();
|
||||
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()
|
||||
{
|
||||
if (m_socks5) {
|
||||
return m_socks5->handshake();
|
||||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_TLS
|
||||
if (isTLS()) {
|
||||
m_expire = Chrono::steadyMSecs() + kResponseTimeout;
|
||||
|
@ -849,6 +861,27 @@ void xmrig::Client::read(ssize_t nread)
|
|||
|
||||
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
|
||||
if (isTLS()) {
|
||||
LOG_DEBUG("[%s] TLS received (%d bytes)", url(), static_cast<int>(nread));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue