p2p: only log to global when a blocked IP is not already blocked

This commit is contained in:
moneromooo-monero 2021-01-01 19:54:18 +00:00 committed by wowario
parent 66f7ea2dbf
commit 9522d66815
No known key found for this signature in database
GPG Key ID: 24DCBE762DE9C111
1 changed files with 8 additions and 1 deletions

View File

@ -234,6 +234,7 @@ namespace nodetool
return false;
const time_t now = time(nullptr);
bool added = false;
CRITICAL_REGION_LOCAL(m_blocked_hosts_lock);
time_t limit;
@ -244,7 +245,10 @@ namespace nodetool
const std::string host_str = addr.host_str();
auto it = m_blocked_hosts.find(host_str);
if (it == m_blocked_hosts.end())
{
m_blocked_hosts[host_str] = limit;
added = true;
}
else if (it->second < limit || !add_only)
it->second = limit;
@ -275,7 +279,10 @@ namespace nodetool
conns.clear();
}
MCLOG_CYAN(el::Level::Info, "global", "Host " << host_str << " blocked.");
if (added)
MCLOG_CYAN(el::Level::Info, "global", "Host " << host_str << " blocked.");
else
MINFO("Host " << host_str << " block time updated.");
return true;
}
//-----------------------------------------------------------------------------------