mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Add IPv6 support
new cli options (RPC ones also apply to wallet): --p2p-bind-ipv6-address (default = "::") --p2p-bind-port-ipv6 (default same as ipv4 port for given nettype) --rpc-bind-ipv6-address (default = "::1") --p2p-use-ipv6 (default false) --rpc-use-ipv6 (default false) --p2p-require-ipv4 (default true, if ipv4 bind fails and this is true, will not continue even if ipv6 bind successful) --rpc-require-ipv4 (default true, description as above) ipv6 addresses are to be specified as "[xx:xx:xx::xx:xx]:port" except in the cases of the cli args for bind address. For those the square braces can be omitted.
This commit is contained in:
parent
8adde33e01
commit
155475d971
20 changed files with 805 additions and 113 deletions
|
@ -11,10 +11,39 @@ namespace net_utils
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
boost::asio::ip::tcp::resolver resolver(GET_IO_SERVICE(timeout));
|
||||
boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), addr, port, boost::asio::ip::tcp::resolver::query::canonical_name);
|
||||
boost::asio::ip::tcp::resolver::iterator iterator = resolver.resolve(query);
|
||||
|
||||
bool try_ipv6 = false;
|
||||
boost::asio::ip::tcp::resolver::iterator iterator;
|
||||
boost::asio::ip::tcp::resolver::iterator end;
|
||||
if(iterator == end) // Documentation states that successful call is guaranteed to be non-empty
|
||||
throw boost::system::system_error{boost::asio::error::fault, "Failed to resolve " + addr};
|
||||
boost::system::error_code resolve_error;
|
||||
try
|
||||
{
|
||||
iterator = resolver.resolve(query, resolve_error);
|
||||
if(iterator == end) // Documentation states that successful call is guaranteed to be non-empty
|
||||
{
|
||||
// if IPv4 resolution fails, try IPv6. Unintentional outgoing IPv6 connections should only
|
||||
// be possible if for some reason a hostname was given and that hostname fails IPv4 resolution,
|
||||
// so at least for now there should not be a need for a flag "using ipv6 is ok"
|
||||
try_ipv6 = true;
|
||||
}
|
||||
|
||||
}
|
||||
catch (const boost::system::system_error& e)
|
||||
{
|
||||
if (resolve_error != boost::asio::error::host_not_found &&
|
||||
resolve_error != boost::asio::error::host_not_found_try_again)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
try_ipv6 = true;
|
||||
}
|
||||
if (try_ipv6)
|
||||
{
|
||||
boost::asio::ip::tcp::resolver::query query6(boost::asio::ip::tcp::v6(), addr, port, boost::asio::ip::tcp::resolver::query::canonical_name);
|
||||
iterator = resolver.resolve(query6);
|
||||
if (iterator == end)
|
||||
throw boost::system::system_error{boost::asio::error::fault, "Failed to resolve " + addr};
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -21,6 +21,19 @@ namespace epee { namespace net_utils
|
|||
bool ipv4_network_address::is_loopback() const { return net_utils::is_ip_loopback(ip()); }
|
||||
bool ipv4_network_address::is_local() const { return net_utils::is_ip_local(ip()); }
|
||||
|
||||
bool ipv6_network_address::equal(const ipv6_network_address& other) const noexcept
|
||||
{ return is_same_host(other) && port() == other.port(); }
|
||||
|
||||
bool ipv6_network_address::less(const ipv6_network_address& other) const noexcept
|
||||
{ return is_same_host(other) ? port() < other.port() : m_address < other.m_address; }
|
||||
|
||||
std::string ipv6_network_address::str() const
|
||||
{ return std::string("[") + host_str() + "]:" + std::to_string(port()); }
|
||||
|
||||
std::string ipv6_network_address::host_str() const { return m_address.to_string(); }
|
||||
bool ipv6_network_address::is_loopback() const { return m_address.is_loopback(); }
|
||||
bool ipv6_network_address::is_local() const { return m_address.is_link_local(); }
|
||||
|
||||
|
||||
bool ipv4_network_subnet::equal(const ipv4_network_subnet& other) const noexcept
|
||||
{ return is_same_host(other) && m_mask == other.m_mask; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue