diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2021-07-27 10:02:26 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2021-08-05 19:05:02 +0000 |
commit | 8eb2b79baddd20d02751d950ee3e2358ba94d203 (patch) | |
tree | 9f1a4a959536c7eb06816070920542dd5bc115b2 /src/p2p/net_node.inl | |
parent | Merge pull request #7734 (diff) | |
download | monero-8eb2b79baddd20d02751d950ee3e2358ba94d203.tar.xz |
p2p: remove blocked addresses/hosts from peerlist
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r-- | src/p2p/net_node.inl | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index eb920d6ce..b8cf2d124 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -269,9 +269,17 @@ namespace nodetool peerlist_entry pe{}; pe.adr = addr; - zone.second.m_peerlist.remove_from_peer_white(pe); - zone.second.m_peerlist.remove_from_peer_gray(pe); - zone.second.m_peerlist.remove_from_peer_anchor(addr); + if (addr.port() == 0) + { + zone.second.m_peerlist.evict_host_from_peerlist(true, pe); + zone.second.m_peerlist.evict_host_from_peerlist(false, pe); + } + else + { + zone.second.m_peerlist.remove_from_peer_white(pe); + zone.second.m_peerlist.remove_from_peer_gray(pe); + zone.second.m_peerlist.remove_from_peer_anchor(addr); + } for (const auto &c: conns) zone.second.m_net_server.get_config_object().close(c); @@ -331,6 +339,13 @@ namespace nodetool for (const auto &c: conns) zone.second.m_net_server.get_config_object().close(c); + for (int i = 0; i < 2; ++i) + zone.second.m_peerlist.filter(i == 0, [&subnet](const peerlist_entry &pe){ + if (pe.adr.get_type_id() != epee::net_utils::ipv4_network_address::get_type_id()) + return false; + return subnet.matches(pe.adr.as<const epee::net_utils::ipv4_network_address>()); + }); + conns.clear(); } |