mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-26 23:27:56 +00:00
p2p: avoid spam blocking ipv4 addresses in a blocked subnet
This commit is contained in:
parent
99be9a044f
commit
f0e326be58
1 changed files with 17 additions and 1 deletions
|
@ -247,6 +247,22 @@ namespace nodetool
|
||||||
if (it == m_blocked_hosts.end())
|
if (it == m_blocked_hosts.end())
|
||||||
{
|
{
|
||||||
m_blocked_hosts[host_str] = limit;
|
m_blocked_hosts[host_str] = limit;
|
||||||
|
|
||||||
|
// 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;
|
added = true;
|
||||||
}
|
}
|
||||||
else if (it->second < limit || !add_only)
|
else if (it->second < limit || !add_only)
|
||||||
|
|
Loading…
Reference in a new issue