aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-03-12 13:44:55 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2016-03-12 13:49:08 +0000
commit789e2755f75dbd2b297b3588404f283568cd8eec (patch)
tree60ea911e8d5f0e854b2d48d8e1558aac195565b9 /src/rpc
parentp2p: lock access to the blocked ips map (diff)
downloadmonero-789e2755f75dbd2b297b3588404f283568cd8eec.tar.xz
rpc: do not return bans if they're effectively spent
The blocked ip list will still hold them till next time a connection attempt is made with that IP, so the effective length of the ban may be negative.
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 3ce4e6006..d9419b2bc 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -950,13 +950,16 @@ namespace cryptonote
return false;
}
+ auto now = time(nullptr);
std::map<uint32_t, time_t> blocked_ips = m_p2p.get_blocked_ips();
for (std::map<uint32_t, time_t>::const_iterator i = blocked_ips.begin(); i != blocked_ips.end(); ++i)
{
- COMMAND_RPC_GETBANS::ban b;
- b.ip = i->first;
- b.seconds = i->second;
- res.bans.push_back(b);
+ if (i->second > now) {
+ COMMAND_RPC_GETBANS::ban b;
+ b.ip = i->first;
+ b.seconds = i->second - now;
+ res.bans.push_back(b);
+ }
}
res.status = CORE_RPC_STATUS_OK;