Skip to content

Commit

Permalink
p2p: avoid spam blocking ipv4 addresses in a blocked subnet
Browse files Browse the repository at this point in the history
  • Loading branch information
moneromooo-monero authored and selsta committed Mar 19, 2023
1 parent 99be9a0 commit f0e326b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/p2p/net_node.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f0e326b

Please sign in to comment.