diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-12-04 22:26:12 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-12-04 22:26:12 +0200 |
commit | 4a0be41dfe85b38bfc9d575ea0fc3e0738a3844b (patch) | |
tree | 948c9ba278f941e9bed7985747ca11a271574e58 /src | |
parent | Merge pull request #1395 (diff) | |
parent | net_node: drop connections from banned IPs after looping through connections (diff) | |
download | monero-4a0be41dfe85b38bfc9d575ea0fc3e0738a3844b.tar.xz |
Merge pull request #1396
7c0dd5e4 net_node: drop connections from banned IPs after looping through connections (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r-- | src/p2p/net_node.inl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 5efd6da13..a8c295ce9 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -203,15 +203,17 @@ namespace nodetool 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) + std::list<boost::uuids::uuid> conns; + m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) { if (cntxt.m_remote_ip == addr) { - drop_connection(cntxt); - return false; + conns.push_back(cntxt.m_connection_id); } return true; - })); + }); + for (const auto &c: conns) + m_net_server.get_config_object().close(c); LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << " blocked.", LOG_LEVEL_0); return true; |