mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 20:19:23 +00:00
Added IPv4 and IPv6 support for SOCKS5.
This commit is contained in:
parent
2fea4e72b5
commit
2e07e69697
2 changed files with 15 additions and 10 deletions
|
@ -59,15 +59,15 @@ void xmrig::Client::Socks5::handshake()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Client::Socks5::isIPv4(const String &) const
|
bool xmrig::Client::Socks5::isIPv4(const String &host, sockaddr_storage *addr) const
|
||||||
{
|
{
|
||||||
return false;
|
return uv_ip4_addr(host.data(), 0, reinterpret_cast<sockaddr_in *>(addr)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool xmrig::Client::Socks5::isIPv6(const String &) const
|
bool xmrig::Client::Socks5::isIPv6(const String &host, sockaddr_storage *addr) const
|
||||||
{
|
{
|
||||||
return false;
|
return uv_ip6_addr(host.data(), 0, reinterpret_cast<sockaddr_in6 *>(addr)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,12 +78,17 @@ void xmrig::Client::Socks5::connect()
|
||||||
|
|
||||||
const auto &host = m_client->pool().host();
|
const auto &host = m_client->pool().host();
|
||||||
std::vector<uint8_t> buf;
|
std::vector<uint8_t> buf;
|
||||||
|
sockaddr_storage addr;
|
||||||
|
|
||||||
if (isIPv4(host)) {
|
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)) {
|
else if (isIPv6(host, &addr)) {
|
||||||
|
buf.resize(22);
|
||||||
|
buf[3] = 0x04;
|
||||||
|
memcpy(buf.data() + 4, &reinterpret_cast<sockaddr_in6 *>(&addr)->sin6_addr, 16);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
buf.resize(host.size() + 7);
|
buf.resize(host.size() + 7);
|
||||||
|
|
|
@ -44,8 +44,8 @@ private:
|
||||||
Ready
|
Ready
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isIPv4(const String &host) const;
|
bool isIPv4(const String &host, sockaddr_storage *addr) const;
|
||||||
bool isIPv6(const String &host) const;
|
bool isIPv6(const String &host, sockaddr_storage *addr) const;
|
||||||
void connect();
|
void connect();
|
||||||
|
|
||||||
Client *m_client;
|
Client *m_client;
|
||||||
|
|
Loading…
Reference in a new issue