diff options
author | luigi1111 <luigi1111w@gmail.com> | 2023-03-24 22:54:32 -0400 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2023-03-24 22:54:32 -0400 |
commit | abe74fda35621f9895439379eb7e49b586fb0edb (patch) | |
tree | 2107250b60f8d105c5cb9bf65cb627b24c07adc8 | |
parent | Merge pull request #8775 (diff) | |
parent | p2p: do not log to global when re-blocking a subnet (diff) | |
download | monero-abe74fda35621f9895439379eb7e49b586fb0edb.tar.xz |
Merge pull request #8770
d7a81cc p2p: do not log to global when re-blocking a subnet (moneromooo-monero)
d84a0d7 p2p: avoid spam blocking ipv4 addresses in a blocked subnet (moneromooo-monero)
-rw-r--r-- | src/p2p/net_node.inl | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index ee6bd8b19..30e3d31b9 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; @@ -317,6 +333,7 @@ namespace nodetool limit = std::numeric_limits<time_t>::max(); else limit = now + seconds; + const bool added = m_blocked_subnets.find(subnet) == m_blocked_subnets.end(); m_blocked_subnets[subnet] = limit; // drop any connection to that subnet. This should only have to look into @@ -349,7 +366,10 @@ namespace nodetool conns.clear(); } - MCLOG_CYAN(el::Level::Info, "global", "Subnet " << subnet.host_str() << " blocked."); + if (added) + MCLOG_CYAN(el::Level::Info, "global", "Subnet " << subnet.host_str() << " blocked."); + else + MINFO("Subnet " << subnet.host_str() << " blocked."); return true; } //----------------------------------------------------------------------------------- |