aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBertrand Jacquin <bertrand@jacquin.bzh>2022-07-17 23:52:34 +0100
committerBertrand Jacquin <bertrand@jacquin.bzh>2024-04-06 21:25:18 +0100
commit8fa4962ae12329fa0965e80b5f945eb2ada63b0e (patch)
tree109333a66bbb9830da60ddf4720816c190234bf8 /src
parentdns: perform AAAA resolution (diff)
downloadmonero-8fa4962ae12329fa0965e80b5f945eb2ada63b0e.tar.xz
net: enable IPv6 by default
As of 2024-04-01, IPv6 represents ~43% of traffic entering Google with up to 75% is some country, and in generally more available when IPv6 was introduced in Monero in 2019 as part of 155475d97196 ("Add IPv6 support"). Monero overall has a very low presence over IPv6 which in part can be explained from the fact that IPv6 need to be specifically enabled before it is used and often requires nodes to be manually added in configuration. This commit enabled IPv6 by default for both RPC and P2P as an attempt to improve Monero network mesh diversity. The change has been tested in a lot of different scenario: IPv4 only, IPv6 only, IPv4+IPv6, IPv4+IPv6 with broken/invalid IPv4 system configuration, IPv4+IPv6 with broken/invalid IPv6 system configuration. * --p2p-use-ipv6 is now deprecated and has no effect * --p2p-ignore-ipv6 is introduced to ignore unsuccessful IPv6 P2P binding * --rpc-use-ipv6 is now deprecated and has no effect * --rpc-ignore-ipv6 is introduced to ignore unsuccessful IPv6 RPC binding See: https://github.com/monero-project/monero/issues/8818 See: https://www.google.com/intl/en/ipv6/statistics.html See: https://www.vyncke.org/ipv6status/
Diffstat (limited to 'src')
-rw-r--r--src/p2p/net_node.cpp3
-rw-r--r--src/p2p/net_node.h11
-rw-r--r--src/p2p/net_node.inl18
-rw-r--r--src/rpc/core_rpc_server.cpp2
-rw-r--r--src/rpc/rpc_args.cpp13
-rw-r--r--src/rpc/rpc_args.h5
-rw-r--r--src/wallet/wallet_rpc_server.cpp2
7 files changed, 35 insertions, 19 deletions
diff --git a/src/p2p/net_node.cpp b/src/p2p/net_node.cpp
index 4d5ba6e38..5ac484ea7 100644
--- a/src/p2p/net_node.cpp
+++ b/src/p2p/net_node.cpp
@@ -159,7 +159,8 @@ namespace nodetool
const command_line::arg_descriptor<bool> arg_no_igd = {"no-igd", "Disable UPnP port mapping"};
const command_line::arg_descriptor<std::string> arg_igd = {"igd", "UPnP port mapping (disabled, enabled, delayed)", "delayed"};
- const command_line::arg_descriptor<bool> arg_p2p_use_ipv6 = {"p2p-use-ipv6", "Enable IPv6 for p2p", false};
+ const command_line::arg_descriptor<bool> arg_p2p_use_ipv6 = {"p2p-use-ipv6", "DEPRECATED, ignored", false};
+ const command_line::arg_descriptor<bool> arg_p2p_ignore_ipv6 = {"p2p-ignore-ipv6", "Ignore unsuccessful IPv6 bind for p2p", false};
const command_line::arg_descriptor<bool> arg_p2p_ignore_ipv4 = {"p2p-ignore-ipv4", "Ignore unsuccessful IPv4 bind for p2p", false};
const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max number of out peers", -1};
const command_line::arg_descriptor<int64_t> arg_in_peers = {"in-peers", "set max number of in peers", -1};
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 4db6a107c..b0218baf1 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -375,11 +375,11 @@ namespace nodetool
bool is_peer_used(const peerlist_entry& peer);
bool is_peer_used(const anchor_peerlist_entry& peer);
bool is_addr_connected(const epee::net_utils::network_address& peer);
- void add_upnp_port_mapping_impl(uint32_t port, bool ipv6=false);
+ void add_upnp_port_mapping_impl(uint32_t port, bool ipv6=true);
void add_upnp_port_mapping_v4(uint32_t port);
void add_upnp_port_mapping_v6(uint32_t port);
- void add_upnp_port_mapping(uint32_t port, bool ipv4=true, bool ipv6=false);
- void delete_upnp_port_mapping_impl(uint32_t port, bool ipv6=false);
+ void add_upnp_port_mapping(uint32_t port, bool ipv4=true, bool ipv6=true);
+ void delete_upnp_port_mapping_impl(uint32_t port, bool ipv6=true);
void delete_upnp_port_mapping_v4(uint32_t port);
void delete_upnp_port_mapping_v6(uint32_t port);
void delete_upnp_port_mapping(uint32_t port);
@@ -457,7 +457,7 @@ namespace nodetool
bool m_hide_my_port;
igd_t m_igd;
bool m_offline;
- bool m_use_ipv6;
+ bool m_require_ipv6;
bool m_require_ipv4;
std::atomic<bool> is_closing;
std::unique_ptr<boost::thread> mPeersLoggerThread;
@@ -527,7 +527,8 @@ namespace nodetool
extern const command_line::arg_descriptor<std::string, false, true, 2> arg_p2p_bind_ipv6_port;
extern const command_line::arg_descriptor<std::string> arg_p2p_bind_port; // DEPRECATED
extern const command_line::arg_descriptor<std::string> arg_p2p_bind_port_ipv6; // DEPRECATED
- extern const command_line::arg_descriptor<bool> arg_p2p_use_ipv6;
+ extern const command_line::arg_descriptor<bool> arg_p2p_use_ipv6; // DEPRECATED
+ extern const command_line::arg_descriptor<bool> arg_p2p_ignore_ipv6;
extern const command_line::arg_descriptor<bool> arg_p2p_ignore_ipv4;
extern const command_line::arg_descriptor<uint32_t> arg_p2p_external_port;
extern const command_line::arg_descriptor<bool> arg_p2p_allow_local_ip;
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index f357c6037..09dead8a7 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -106,7 +106,8 @@ namespace nodetool
command_line::add_arg(desc, arg_p2p_bind_ipv6_port, false);
command_line::add_arg(desc, arg_p2p_bind_port, false); // DEPRECATED
command_line::add_arg(desc, arg_p2p_bind_port_ipv6, false); // DEPRECATED
- command_line::add_arg(desc, arg_p2p_use_ipv6);
+ command_line::add_arg(desc, arg_p2p_use_ipv6); // DEPRECATED
+ command_line::add_arg(desc, arg_p2p_ignore_ipv6);
command_line::add_arg(desc, arg_p2p_ignore_ipv4);
command_line::add_arg(desc, arg_p2p_external_port);
command_line::add_arg(desc, arg_p2p_allow_local_ip);
@@ -471,8 +472,13 @@ namespace nodetool
return false;
}
m_offline = command_line::get_arg(vm, cryptonote::arg_offline);
- m_use_ipv6 = command_line::get_arg(vm, arg_p2p_use_ipv6);
+ m_require_ipv6 = !command_line::get_arg(vm, arg_p2p_ignore_ipv6);
m_require_ipv4 = !command_line::get_arg(vm, arg_p2p_ignore_ipv4);
+
+ // DEPRECATED --p2p-use-ipv6
+ if (command_line::get_arg(vm, arg_p2p_use_ipv6))
+ MWARNING("--p2p-use-ipv6 is now DEPRECATED and has no effect");
+
public_zone.m_notifier = cryptonote::levin::notify{
public_zone.m_net_server.get_io_service(), public_zone.m_net_server.get_config_shared(), nullptr, epee::net_utils::zone::public_, pad_txs, m_payload_handler.get_core()
};
@@ -1012,20 +1018,20 @@ namespace nodetool
std::string ipv6_port = "";
zone.second.m_net_server.set_connection_filter(this);
MINFO("Binding (IPv4) on " << zone.second.m_bind_ipv4_address << ":" << zone.second.m_port_ipv4);
- if (!zone.second.m_bind_ipv6_address.empty() && m_use_ipv6)
+ if (!zone.second.m_bind_ipv6_address.empty() && m_require_ipv6)
{
ipv6_addr = zone.second.m_bind_ipv6_address;
ipv6_port = zone.second.m_port_ipv6;
MINFO("Binding (IPv6) on " << zone.second.m_bind_ipv6_address << ":" << zone.second.m_port_ipv6);
}
- res = zone.second.m_net_server.init_server(zone.second.m_port_ipv4, zone.second.m_bind_ipv4_address, ipv6_port, ipv6_addr, m_use_ipv6, m_require_ipv4, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
+ res = zone.second.m_net_server.init_server(zone.second.m_port_ipv4, zone.second.m_bind_ipv4_address, ipv6_port, ipv6_addr, m_require_ipv6, m_require_ipv4, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
CHECK_AND_ASSERT_MES(res, false, "Failed to bind server");
}
}
m_listening_port_ipv4 = public_zone.m_net_server.get_binded_port_ipv4();
MLOG_GREEN(el::Level::Info, "Net service bound (IPv4) to " << public_zone.m_bind_ipv4_address << ":" << m_listening_port_ipv4);
- if (m_use_ipv6)
+ if (m_require_ipv6)
{
m_listening_port_ipv6 = public_zone.m_net_server.get_binded_port_ipv6();
MLOG_GREEN(el::Level::Info, "Net service bound (IPv6) to " << public_zone.m_bind_ipv6_address << ":" << m_listening_port_ipv6);
@@ -1037,7 +1043,7 @@ namespace nodetool
if(m_igd == igd)
{
add_upnp_port_mapping_v4(m_listening_port_ipv4);
- if (m_use_ipv6)
+ if (m_require_ipv6)
{
add_upnp_port_mapping_v6(m_listening_port_ipv6);
}
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 0ce1346cc..642c8a790 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -399,7 +399,7 @@ namespace cryptonote
auto rng = [](size_t len, uint8_t *ptr){ return crypto::rand(len, ptr); };
const bool inited = epee::http_server_impl_base<core_rpc_server, connection_context>::init(
rng, std::move(port), std::move(bind_ipv4_str),
- std::move(bind_ipv6_str), std::move(rpc_config->use_ipv6), std::move(rpc_config->require_ipv4),
+ std::move(bind_ipv6_str), std::move(rpc_config->require_ipv6), std::move(rpc_config->require_ipv4),
std::move(rpc_config->access_control_origins), std::move(http_login), std::move(rpc_config->ssl_options)
);
diff --git a/src/rpc/rpc_args.cpp b/src/rpc/rpc_args.cpp
index 4d0411b50..8ca7e5c7a 100644
--- a/src/rpc/rpc_args.cpp
+++ b/src/rpc/rpc_args.cpp
@@ -95,7 +95,8 @@ namespace cryptonote
, rpc_restricted_bind_ipv4_address({"rpc-restricted-bind-ipv4-address", rpc_args::tr("Specify IPv4 address to bind restricted RPC server"), "127.0.0.1"})
, rpc_restricted_bind_ipv6_address({"rpc-restricted-bind-ipv6-address", rpc_args::tr("Specify IPv6 address to bind restricted RPC server"), "::1"})
, rpc_restricted_bind_ip({"rpc-restricted-bind-ip", rpc_args::tr("DEPRECATED: replaced with --rpc-restricted-bind-ipv4-address"), ""})
- , rpc_use_ipv6({"rpc-use-ipv6", rpc_args::tr("Allow IPv6 for RPC"), false})
+ , rpc_use_ipv6({"rpc-use-ipv6", rpc_args::tr("DEPRECATED, ignored"), false})
+ , rpc_ignore_ipv6({"rpc-ignore-ipv6", rpc_args::tr("Ignore unsuccessful IPv6 bind for RPC"), false})
, rpc_ignore_ipv4({"rpc-ignore-ipv4", rpc_args::tr("Ignore unsuccessful IPv4 bind for RPC"), false})
, rpc_login({"rpc-login", rpc_args::tr("Specify username[:password] required for RPC server"), "", true})
, confirm_external_bind({"confirm-external-bind", rpc_args::tr("Confirm rpc-bind-ipv4-address value is NOT a loopback (local) IP")})
@@ -121,7 +122,8 @@ namespace cryptonote
command_line::add_arg(desc, arg.rpc_restricted_bind_ipv4_address);
command_line::add_arg(desc, arg.rpc_restricted_bind_ipv6_address);
command_line::add_arg(desc, arg.rpc_restricted_bind_ip); // DEPRECATED
- command_line::add_arg(desc, arg.rpc_use_ipv6);
+ command_line::add_arg(desc, arg.rpc_use_ipv6); // DEPRECATED
+ command_line::add_arg(desc, arg.rpc_ignore_ipv6);
command_line::add_arg(desc, arg.rpc_ignore_ipv4);
command_line::add_arg(desc, arg.rpc_login);
command_line::add_arg(desc, arg.confirm_external_bind);
@@ -159,8 +161,13 @@ namespace cryptonote
if (config.restricted_bind_ipv4_address.empty())
config.restricted_bind_ipv4_address = command_line::get_arg(vm, arg.rpc_restricted_bind_ip);
- config.use_ipv6 = command_line::get_arg(vm, arg.rpc_use_ipv6);
+ config.require_ipv6 = !command_line::get_arg(vm, arg.rpc_ignore_ipv6);
config.require_ipv4 = !command_line::get_arg(vm, arg.rpc_ignore_ipv4);
+
+ // DEPRECATED --rpc-use-ipv6
+ if (command_line::get_arg(vm, arg.rpc_use_ipv6))
+ MWARNING("--rpc-use-ipv6 is now DEPRECATED and has no effect");
+
config.disable_rpc_ban = command_line::get_arg(vm, arg.disable_rpc_ban);
if (!config.bind_ipv4_address.empty())
{
diff --git a/src/rpc/rpc_args.h b/src/rpc/rpc_args.h
index 392e78703..ea3cad8b3 100644
--- a/src/rpc/rpc_args.h
+++ b/src/rpc/rpc_args.h
@@ -57,7 +57,8 @@ namespace cryptonote
const command_line::arg_descriptor<std::string> rpc_restricted_bind_ipv4_address;
const command_line::arg_descriptor<std::string> rpc_restricted_bind_ipv6_address;
const command_line::arg_descriptor<std::string> rpc_restricted_bind_ip; // DEPRECATED
- const command_line::arg_descriptor<bool> rpc_use_ipv6;
+ const command_line::arg_descriptor<bool> rpc_use_ipv6; // DEPRECATED
+ const command_line::arg_descriptor<bool> rpc_ignore_ipv6;
const command_line::arg_descriptor<bool> rpc_ignore_ipv4;
const command_line::arg_descriptor<std::string> rpc_login;
const command_line::arg_descriptor<bool> confirm_external_bind;
@@ -87,7 +88,7 @@ namespace cryptonote
std::string bind_ipv6_address;
std::string restricted_bind_ipv4_address;
std::string restricted_bind_ipv6_address;
- bool use_ipv6;
+ bool require_ipv6;
bool require_ipv4;
std::vector<std::string> access_control_origins;
boost::optional<tools::login> login; // currently `boost::none` if unspecified by user
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index f5e3c4b4e..616930421 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -281,7 +281,7 @@ namespace tools
auto rng = [](size_t len, uint8_t *ptr) { return crypto::rand(len, ptr); };
return epee::http_server_impl_base<wallet_rpc_server, connection_context>::init(
rng, std::move(bind_port), std::move(rpc_config->bind_ipv4_address),
- std::move(rpc_config->bind_ipv6_address), std::move(rpc_config->use_ipv6), std::move(rpc_config->require_ipv4),
+ std::move(rpc_config->bind_ipv6_address), std::move(rpc_config->require_ipv6), std::move(rpc_config->require_ipv4),
std::move(rpc_config->access_control_origins), std::move(http_login),
std::move(rpc_config->ssl_options)
);