aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-11-29 01:46:46 -0600
committerluigi1111 <luigi1111w@gmail.com>2020-11-29 01:46:46 -0600
commit2be7a4c04f208b2461f91b7245feab3ba3013d72 (patch)
treeb0bef2529556b79073fc96f2162bae59d28bb0a7
parentMerge pull request #6924 (diff)
parentp2p: use /16 filtering on IPv4-within-IPv6 addresses (diff)
downloadmonero-2be7a4c04f208b2461f91b7245feab3ba3013d72.tar.xz
Merge pull request #6933
1f04a31 p2p: use /16 filtering on IPv4-within-IPv6 addresses (moneromooo-monero)
-rw-r--r--src/p2p/net_node.inl32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 81002baa4..055d3507e 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -1480,6 +1480,20 @@ namespace nodetool
const uint32_t actual_ip = na.as<const epee::net_utils::ipv4_network_address>().ip();
classB.insert(actual_ip & 0x0000ffff);
}
+#if BOOST_VERSION > 106600
+ else if (cntxt.m_remote_address.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
+ {
+ const epee::net_utils::network_address na = cntxt.m_remote_address;
+ const boost::asio::ip::address_v6 &actual_ip = na.as<const epee::net_utils::ipv6_network_address>().ip();
+ if (actual_ip.is_v4_mapped())
+ {
+ boost::asio::ip::address_v4 v4ip = make_address_v4(boost::asio::ip::v4_mapped, actual_ip);
+ uint32_t actual_ipv4;
+ memcpy(&actual_ipv4, v4ip.to_bytes().data(), sizeof(actual_ipv4));
+ classB.insert(actual_ipv4 & ntohl(0xffff0000));
+ }
+ }
+#endif
return true;
});
}
@@ -1500,6 +1514,20 @@ namespace nodetool
uint32_t actual_ip = na.as<const epee::net_utils::ipv4_network_address>().ip();
skip = classB.find(actual_ip & 0x0000ffff) != classB.end();
}
+#if BOOST_VERSION > 106600
+ else if (skip_duplicate_class_B && pe.adr.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
+ {
+ const epee::net_utils::network_address na = pe.adr;
+ const boost::asio::ip::address_v6 &actual_ip = na.as<const epee::net_utils::ipv6_network_address>().ip();
+ if (actual_ip.is_v4_mapped())
+ {
+ boost::asio::ip::address_v4 v4ip = make_address_v4(boost::asio::ip::v4_mapped, actual_ip);
+ uint32_t actual_ipv4;
+ memcpy(&actual_ipv4, v4ip.to_bytes().data(), sizeof(actual_ipv4));
+ skip = classB.find(actual_ipv4 & ntohl(0xffff0000)) != classB.end();
+ }
+ }
+#endif
if (skip)
++skipped;
else if (next_needed_pruning_stripe == 0 || pe.pruning_seed == 0)
@@ -1512,11 +1540,11 @@ namespace nodetool
if (skipped == 0 || !filtered.empty())
break;
if (skipped)
- MINFO("Skipping " << skipped << " possible peers as they share a class B with existing peers");
+ MDEBUG("Skipping " << skipped << " possible peers as they share a class B with existing peers");
}
if (filtered.empty())
{
- MDEBUG("No available peer in " << (use_white_list ? "white" : "gray") << " list filtered by " << next_needed_pruning_stripe);
+ MINFO("No available peer in " << (use_white_list ? "white" : "gray") << " list filtered by " << next_needed_pruning_stripe);
return false;
}
if (use_white_list)