mirror of
https://github.com/monero-project/monero.git
synced 2024-12-15 12:56:33 +02:00
p2p: drop any existing connection to a banned IP
This commit is contained in:
parent
8f94fcf6a3
commit
e57379a819
@ -200,6 +200,18 @@ namespace nodetool
|
|||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_blocked_ips_lock);
|
CRITICAL_REGION_LOCAL(m_blocked_ips_lock);
|
||||||
m_blocked_ips[addr] = time(nullptr) + seconds;
|
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);
|
LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << " blocked.", LOG_LEVEL_0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user