diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-03-12 16:21:20 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-03-12 16:21:20 +0200 |
commit | b66d4555360b0b8634022b5171f41fcee940bc1e (patch) | |
tree | 3cf22d725a94b2602ba13270067efb0ef59c21a1 /src | |
parent | Merge pull request #715 (diff) | |
parent | rpc: do not return bans if they're effectively spent (diff) | |
download | monero-b66d4555360b0b8634022b5171f41fcee940bc1e.tar.xz |
Merge pull request #716
789e275 rpc: do not return bans if they're effectively spent (moneromooo-monero)
474e4c0 p2p: lock access to the blocked ips map (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r-- | src/p2p/net_node.h | 2 | ||||
-rw-r--r-- | src/p2p/net_node_common.h | 4 | ||||
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 11 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index 260dd813d..5943c248f 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -120,7 +120,7 @@ namespace nodetool void delete_connections(size_t count); virtual bool block_ip(uint32_t adress, time_t seconds = P2P_IP_BLOCKTIME); virtual bool unblock_ip(uint32_t address); - virtual std::map<uint32_t, time_t> get_blocked_ips() const { return m_blocked_ips; } + virtual std::map<uint32_t, time_t> get_blocked_ips() { CRITICAL_REGION_LOCAL(m_blocked_ips_lock); return m_blocked_ips; } private: const std::vector<std::string> m_seed_nodes_list = { "seeds.moneroseeds.se" diff --git a/src/p2p/net_node_common.h b/src/p2p/net_node_common.h index 68b0bd1ee..5e7645365 100644 --- a/src/p2p/net_node_common.h +++ b/src/p2p/net_node_common.h @@ -52,7 +52,7 @@ namespace nodetool virtual void for_each_connection(std::function<bool(t_connection_context&, peerid_type)> f)=0; virtual bool block_ip(uint32_t adress, time_t seconds = 0)=0; virtual bool unblock_ip(uint32_t adress)=0; - virtual std::map<uint32_t, time_t> get_blocked_ips()const=0; + virtual std::map<uint32_t, time_t> get_blocked_ips()=0; virtual bool add_ip_fail(uint32_t adress)=0; }; @@ -96,7 +96,7 @@ namespace nodetool { return true; } - virtual std::map<uint32_t, time_t> get_blocked_ips() const + virtual std::map<uint32_t, time_t> get_blocked_ips() { return std::map<uint32_t, time_t>(); } 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; |