mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-07 16:05:05 -05:00
Improved IPv6 support.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* XMRig
|
||||
* Copyright (c) 2018-2021 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2021 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2025 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2025 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
|
||||
@@ -20,15 +20,15 @@
|
||||
#include "3rdparty/rapidjson/document.h"
|
||||
#include "base/io/json/Json.h"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <uv.h>
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
const char *DnsConfig::kField = "dns";
|
||||
const char *DnsConfig::kIPv6 = "ipv6";
|
||||
const char *DnsConfig::kIPv = "ip_version";
|
||||
const char *DnsConfig::kTTL = "ttl";
|
||||
|
||||
|
||||
@@ -37,8 +37,26 @@ const char *DnsConfig::kTTL = "ttl";
|
||||
|
||||
xmrig::DnsConfig::DnsConfig(const rapidjson::Value &value)
|
||||
{
|
||||
m_ipv6 = Json::getBool(value, kIPv6, m_ipv6);
|
||||
m_ttl = std::max(Json::getUint(value, kTTL, m_ttl), 1U);
|
||||
const uint32_t ipv = Json::getUint(value, kIPv, m_ipv);
|
||||
if (ipv == 0 || ipv == 4 || ipv == 6) {
|
||||
m_ipv = ipv;
|
||||
}
|
||||
|
||||
m_ttl = std::max(Json::getUint(value, kTTL, m_ttl), 1U);
|
||||
}
|
||||
|
||||
|
||||
int xmrig::DnsConfig::ai_family() const
|
||||
{
|
||||
if (m_ipv == 4) {
|
||||
return AF_INET;
|
||||
}
|
||||
|
||||
if (m_ipv == 6) {
|
||||
return AF_INET6;
|
||||
}
|
||||
|
||||
return AF_UNSPEC;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +67,8 @@ rapidjson::Value xmrig::DnsConfig::toJSON(rapidjson::Document &doc) const
|
||||
auto &allocator = doc.GetAllocator();
|
||||
Value obj(kObjectType);
|
||||
|
||||
obj.AddMember(StringRef(kIPv6), m_ipv6, allocator);
|
||||
obj.AddMember(StringRef(kTTL), m_ttl, allocator);
|
||||
obj.AddMember(StringRef(kIPv), m_ipv, allocator);
|
||||
obj.AddMember(StringRef(kTTL), m_ttl, allocator);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user