aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-10-04 12:14:41 +0200
committerRiccardo Spagni <ric@spagni.net>2016-10-04 12:14:41 +0200
commite72b6a7ade829e560846f0e3e58cca42252e73ce (patch)
tree2c04f8ed84d2d261dcf28cf0f8aafbab2aa43f45 /src/p2p
parentMerge pull request #1164 (diff)
parentp2p: drop any existing connection to a banned IP (diff)
downloadmonero-e72b6a7ade829e560846f0e3e58cca42252e73ce.tar.xz
Merge pull request #1165
e57379a p2p: drop any existing connection to a banned IP (moneromooo-monero)
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.inl12
1 files changed, 12 insertions, 0 deletions
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;
}