mirror of
https://github.com/wownero/wownero.git
synced 2026-12-03 06:24:11 +01:00
Merge pull request #11084
4b3eabf daemon: add unban all command (Rene Guenon)
ACKs: selsta, jpk68, thomasbuilds
This commit is contained in:
@@ -240,8 +240,8 @@ t_command_server::t_command_server(
|
||||
m_command_lookup.set_handler(
|
||||
"unban"
|
||||
, std::bind(&t_command_parser_executor::unban, &m_parser, p::_1)
|
||||
, "unban <address>"
|
||||
, "Unban a given <IP>."
|
||||
, "unban <address>|all"
|
||||
, "Unban a given <address>, or all banned addresses."
|
||||
);
|
||||
m_command_lookup.set_handler(
|
||||
"banned"
|
||||
|
||||
@@ -280,6 +280,7 @@ namespace nodetool
|
||||
virtual bool unblock_host(const epee::net_utils::network_address &address);
|
||||
virtual bool block_subnet(const epee::net_utils::ipv4_network_subnet &subnet, time_t seconds = P2P_IP_BLOCKTIME);
|
||||
virtual bool unblock_subnet(const epee::net_utils::ipv4_network_subnet &subnet);
|
||||
virtual bool clear_bans();
|
||||
virtual bool is_host_blocked(const epee::net_utils::network_address &address, time_t *seconds) { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return !is_remote_host_allowed(address, seconds); }
|
||||
virtual std::map<std::string, time_t> get_blocked_hosts() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_hosts; }
|
||||
virtual std::map<epee::net_utils::ipv4_network_subnet, time_t> get_blocked_subnets() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_subnets; }
|
||||
|
||||
@@ -520,6 +520,18 @@ namespace nodetool
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::clear_bans()
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_blocked_hosts_lock);
|
||||
const bool had_bans = !m_blocked_hosts.empty() || !m_blocked_subnets.empty();
|
||||
m_blocked_hosts.clear();
|
||||
m_blocked_subnets.clear();
|
||||
if (had_bans)
|
||||
MCLOG_CYAN(el::Level::Info, "global", "All bans cleared.");
|
||||
return had_bans;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::add_host_fail(const epee::net_utils::network_address &address, unsigned int score)
|
||||
{
|
||||
if(!address.is_blockable())
|
||||
|
||||
@@ -2375,6 +2375,12 @@ namespace cryptonote
|
||||
{
|
||||
epee::net_utils::network_address na;
|
||||
|
||||
if (!i->ban && i->host == "all")
|
||||
{
|
||||
m_p2p.clear_bans();
|
||||
continue;
|
||||
}
|
||||
|
||||
// try subnet first
|
||||
if (!i->host.empty())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user