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
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
#include <typeinfo>
|
||||
#include <type_traits>
|
||||
#include "enums.h"
|
||||
|
@ -154,6 +155,59 @@ namespace net_utils
|
|||
inline bool operator>=(const ipv4_network_subnet& lhs, const ipv4_network_subnet& rhs) noexcept
|
||||
{ return !lhs.less(rhs); }
|
||||
|
||||
class ipv6_network_address
|
||||
{
|
||||
protected:
|
||||
boost::asio::ip::address_v6 m_address;
|
||||
uint16_t m_port;
|
||||
|
||||
public:
|
||||
ipv6_network_address()
|
||||
: ipv6_network_address(boost::asio::ip::address_v6::loopback(), 0)
|
||||
{}
|
||||
|
||||
ipv6_network_address(const boost::asio::ip::address_v6& ip, uint16_t port)
|
||||
: m_address(ip), m_port(port)
|
||||
{
|
||||
}
|
||||
|
||||
bool equal(const ipv6_network_address& other) const noexcept;
|
||||
bool less(const ipv6_network_address& other) const noexcept;
|
||||
bool is_same_host(const ipv6_network_address& other) const noexcept
|
||||
{ return m_address == other.m_address; }
|
||||
|
||||
boost::asio::ip::address_v6 ip() const noexcept { return m_address; }
|
||||
uint16_t port() const noexcept { return m_port; }
|
||||
std::string str() const;
|
||||
std::string host_str() const;
|
||||
bool is_loopback() const;
|
||||
bool is_local() const;
|
||||
static constexpr address_type get_type_id() noexcept { return address_type::ipv6; }
|
||||
static constexpr zone get_zone() noexcept { return zone::public_; }
|
||||
static constexpr bool is_blockable() noexcept { return true; }
|
||||
|
||||
static const uint8_t ID = 2;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
boost::asio::ip::address_v6::bytes_type bytes = this_ref.m_address.to_bytes();
|
||||
epee::serialization::selector<is_store>::serialize_t_val_as_blob(bytes, stg, hparent_section, "addr");
|
||||
const_cast<boost::asio::ip::address_v6&>(this_ref.m_address) = boost::asio::ip::address_v6(bytes);
|
||||
KV_SERIALIZE(m_port)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
inline bool operator==(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
|
||||
{ return lhs.equal(rhs); }
|
||||
inline bool operator!=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
|
||||
{ return !lhs.equal(rhs); }
|
||||
inline bool operator<(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
|
||||
{ return lhs.less(rhs); }
|
||||
inline bool operator<=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
|
||||
{ return !rhs.less(lhs); }
|
||||
inline bool operator>(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
|
||||
{ return rhs.less(lhs); }
|
||||
inline bool operator>=(const ipv6_network_address& lhs, const ipv6_network_address& rhs) noexcept
|
||||
{ return !lhs.less(rhs); }
|
||||
|
||||
class network_address
|
||||
{
|
||||
struct interface
|
||||
|
@ -261,6 +315,8 @@ namespace net_utils
|
|||
{
|
||||
case address_type::ipv4:
|
||||
return this_ref.template serialize_addr<ipv4_network_address>(is_store_, stg, hparent_section);
|
||||
case address_type::ipv6:
|
||||
return this_ref.template serialize_addr<ipv6_network_address>(is_store_, stg, hparent_section);
|
||||
case address_type::tor:
|
||||
return this_ref.template serialize_addr<net::tor_address>(is_store_, stg, hparent_section);
|
||||
case address_type::i2p:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue