From e57379a819ebafb0871ac591611a2f8f2085be34 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 2 Oct 2016 17:39:21 +0100 Subject: p2p: drop any existing connection to a banned IP --- src/p2p/net_node.inl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/p2p') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 9c1d8629d..04d73ba95 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -200,6 +200,18 @@ namespace nodetool { CRITICAL_REGION_LOCAL(m_blocked_ips_lock); m_blocked_ips[addr] = time(nullptr) + seconds; + + // drop any connection to that IP + while (!m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) + { + if (cntxt.m_remote_ip == addr) + { + drop_connection(cntxt); + return false; + } + return true; + })); + LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << " blocked.", LOG_LEVEL_0); return true; } -- cgit v1.2.3