mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
Merge pull request #8787
c4cfaa4
p2p: do not log to global when re-blocking a subnet (moneromooo-monero)f0e326b
p2p: avoid spam blocking ipv4 addresses in a blocked subnet (moneromooo-monero)
This commit is contained in:
commit
0e2c2ddd9c
@ -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)
|
||||||
@ -317,6 +333,7 @@ namespace nodetool
|
|||||||
limit = std::numeric_limits<time_t>::max();
|
limit = std::numeric_limits<time_t>::max();
|
||||||
else
|
else
|
||||||
limit = now + seconds;
|
limit = now + seconds;
|
||||||
|
const bool added = m_blocked_subnets.find(subnet) == m_blocked_subnets.end();
|
||||||
m_blocked_subnets[subnet] = limit;
|
m_blocked_subnets[subnet] = limit;
|
||||||
|
|
||||||
// drop any connection to that subnet. This should only have to look into
|
// drop any connection to that subnet. This should only have to look into
|
||||||
@ -349,7 +366,10 @@ namespace nodetool
|
|||||||
conns.clear();
|
conns.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (added)
|
||||||
MCLOG_CYAN(el::Level::Info, "global", "Subnet " << subnet.host_str() << " blocked.");
|
MCLOG_CYAN(el::Level::Info, "global", "Subnet " << subnet.host_str() << " blocked.");
|
||||||
|
else
|
||||||
|
MINFO("Subnet " << subnet.host_str() << " blocked.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user