aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/net_node.inl
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-11-25 22:04:27 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-11-25 22:23:04 +0000
commit7bc4dce6ede055be5f6d494766eb31b9e68ae8a1 (patch)
treeb0e0f292620991498dc20fd186784f78badb87cb /src/p2p/net_node.inl
parentMerge pull request #501 (diff)
downloadmonero-7bc4dce6ede055be5f6d494766eb31b9e68ae8a1.tar.xz
net_node: allow bans for custom amounts of time
m_blocked_ips now stores the unblocking time, rather than the blocking time. Also change > to >=, since banning for 0 seconds should not ban
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r--src/p2p/net_node.inl6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 11df7ee49..f15e60201 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -169,7 +169,7 @@ namespace nodetool
auto it = m_blocked_ips.find(addr);
if(it == m_blocked_ips.end())
return true;
- if(time(nullptr) - it->second > P2P_IP_BLOCKTIME )
+ if(time(nullptr) >= it->second)
{
m_blocked_ips.erase(it);
LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << "is unblocked.", LOG_LEVEL_0);
@@ -186,10 +186,10 @@ namespace nodetool
}
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
- bool node_server<t_payload_net_handler>::block_ip(uint32_t addr)
+ bool node_server<t_payload_net_handler>::block_ip(uint32_t addr, uint32_t seconds)
{
CRITICAL_REGION_LOCAL(m_blocked_ips_lock);
- m_blocked_ips[addr] = time(nullptr);
+ m_blocked_ips[addr] = time(nullptr) + seconds;
LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << " blocked.", LOG_LEVEL_0);
return true;
}