aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2023-03-01 16:56:17 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2023-03-01 16:56:56 +0000
commitd84a0d7430c1c559ec870de14e15151b94ec3c38 (patch)
treeb69411197df74ba1297155f3f6ee3b12906b7a3d /src
parentMerge pull request #8713 (diff)
downloadmonero-d84a0d7430c1c559ec870de14e15151b94ec3c38.tar.xz
p2p: avoid spam blocking ipv4 addresses in a blocked subnet
Diffstat (limited to 'src')
-rw-r--r--src/p2p/net_node.inl18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index df67734d5..70b8b176e 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -247,7 +247,23 @@ namespace nodetool
if (it == m_blocked_hosts.end())
{
m_blocked_hosts[host_str] = limit;
- added = true;
+
+ // if the host was already blocked due to being in a blocked subnet, let it be silent
+ bool matches_blocked_subnet = false;
+ if (addr.get_type_id() == epee::net_utils::address_type::ipv4)
+ {
+ auto ipv4_address = addr.template as<epee::net_utils::ipv4_network_address>();
+ for (auto jt = m_blocked_subnets.begin(); jt != m_blocked_subnets.end(); ++jt)
+ {
+ if (jt->first.matches(ipv4_address))
+ {
+ matches_blocked_subnet = true;
+ break;
+ }
+ }
+ }
+ if (!matches_blocked_subnet)
+ added = true;
}
else if (it->second < limit || !add_only)
it->second = limit;