p2p: only try to connect to IPv6 addresses if using --p2p-use-ipv6

This commit is contained in:
moneromooo-monero 2021-01-09 01:29:31 +00:00
parent 964ad0e51a
commit 70e62a029c
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -1352,6 +1352,9 @@ namespace nodetool
} }
if (!m_use_ipv6 && na.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
return false;
MDEBUG("Connecting to " << na.str() << "(peer_type=" << peer_type << ", last_seen: " MDEBUG("Connecting to " << na.str() << "(peer_type=" << peer_type << ", last_seen: "
<< (last_seen_stamp ? epee::misc_utils::get_time_interval_string(time(NULL) - last_seen_stamp):"never") << (last_seen_stamp ? epee::misc_utils::get_time_interval_string(time(NULL) - last_seen_stamp):"never")
<< ")..."); << ")...");
@ -1596,6 +1599,9 @@ namespace nodetool
} }
} }
if (!skip && !m_use_ipv6 && pe.adr.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
skip = true;
// consider each host once, to avoid giving undue inflence to hosts running several nodes // consider each host once, to avoid giving undue inflence to hosts running several nodes
if (!skip) if (!skip)
{ {
@ -2876,6 +2882,8 @@ namespace nodetool
peerlist_entry pe{}; peerlist_entry pe{};
if (!zone.second.m_peerlist.get_random_gray_peer(pe)) if (!zone.second.m_peerlist.get_random_gray_peer(pe))
continue; continue;
if (!m_use_ipv6 && pe.adr.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
continue;
if (!check_connection_and_handshake_with_peer(pe.adr, pe.last_seen)) if (!check_connection_and_handshake_with_peer(pe.adr, pe.last_seen))
{ {