mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 04:38:53 +00:00
p2p: store network address directly in blocked host list
rather than their string representation
This commit is contained in:
parent
fd3ff74164
commit
515ac2951d
@ -248,7 +248,7 @@ namespace nodetool
|
|||||||
void change_max_in_public_peers(size_t count);
|
void change_max_in_public_peers(size_t count);
|
||||||
virtual bool block_host(const epee::net_utils::network_address &adress, time_t seconds = P2P_IP_BLOCKTIME);
|
virtual bool block_host(const epee::net_utils::network_address &adress, time_t seconds = P2P_IP_BLOCKTIME);
|
||||||
virtual bool unblock_host(const epee::net_utils::network_address &address);
|
virtual bool unblock_host(const epee::net_utils::network_address &address);
|
||||||
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::network_address, time_t> get_blocked_hosts() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_hosts; }
|
||||||
|
|
||||||
virtual void add_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
|
virtual void add_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
|
||||||
virtual void remove_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
|
virtual void remove_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
|
||||||
@ -462,7 +462,7 @@ namespace nodetool
|
|||||||
epee::critical_section m_conn_fails_cache_lock;
|
epee::critical_section m_conn_fails_cache_lock;
|
||||||
|
|
||||||
epee::critical_section m_blocked_hosts_lock;
|
epee::critical_section m_blocked_hosts_lock;
|
||||||
std::map<std::string, time_t> m_blocked_hosts;
|
std::map<epee::net_utils::network_address, time_t> m_blocked_hosts;
|
||||||
|
|
||||||
epee::critical_section m_host_fails_score_lock;
|
epee::critical_section m_host_fails_score_lock;
|
||||||
std::map<std::string, uint64_t> m_host_fails_score;
|
std::map<std::string, uint64_t> m_host_fails_score;
|
||||||
|
@ -158,7 +158,7 @@ namespace nodetool
|
|||||||
bool node_server<t_payload_net_handler>::is_remote_host_allowed(const epee::net_utils::network_address &address)
|
bool node_server<t_payload_net_handler>::is_remote_host_allowed(const epee::net_utils::network_address &address)
|
||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_blocked_hosts_lock);
|
CRITICAL_REGION_LOCAL(m_blocked_hosts_lock);
|
||||||
auto it = m_blocked_hosts.find(address.host_str());
|
auto it = m_blocked_hosts.find(address);
|
||||||
if(it == m_blocked_hosts.end())
|
if(it == m_blocked_hosts.end())
|
||||||
return true;
|
return true;
|
||||||
if(time(nullptr) >= it->second)
|
if(time(nullptr) >= it->second)
|
||||||
@ -184,7 +184,7 @@ namespace nodetool
|
|||||||
limit = std::numeric_limits<time_t>::max();
|
limit = std::numeric_limits<time_t>::max();
|
||||||
else
|
else
|
||||||
limit = now + seconds;
|
limit = now + seconds;
|
||||||
m_blocked_hosts[addr.host_str()] = limit;
|
m_blocked_hosts[addr] = limit;
|
||||||
|
|
||||||
// drop any connection to that address. This should only have to look into
|
// drop any connection to that address. This should only have to look into
|
||||||
// the zone related to the connection, but really make sure everything is
|
// the zone related to the connection, but really make sure everything is
|
||||||
@ -214,7 +214,7 @@ namespace nodetool
|
|||||||
bool node_server<t_payload_net_handler>::unblock_host(const epee::net_utils::network_address &address)
|
bool node_server<t_payload_net_handler>::unblock_host(const epee::net_utils::network_address &address)
|
||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_blocked_hosts_lock);
|
CRITICAL_REGION_LOCAL(m_blocked_hosts_lock);
|
||||||
auto i = m_blocked_hosts.find(address.host_str());
|
auto i = m_blocked_hosts.find(address);
|
||||||
if (i == m_blocked_hosts.end())
|
if (i == m_blocked_hosts.end())
|
||||||
return false;
|
return false;
|
||||||
m_blocked_hosts.erase(i);
|
m_blocked_hosts.erase(i);
|
||||||
|
@ -56,7 +56,7 @@ namespace nodetool
|
|||||||
virtual bool for_connection(const boost::uuids::uuid&, std::function<bool(t_connection_context&, peerid_type, uint32_t)> f)=0;
|
virtual bool for_connection(const boost::uuids::uuid&, std::function<bool(t_connection_context&, peerid_type, uint32_t)> f)=0;
|
||||||
virtual bool block_host(const epee::net_utils::network_address &address, time_t seconds = 0)=0;
|
virtual bool block_host(const epee::net_utils::network_address &address, time_t seconds = 0)=0;
|
||||||
virtual bool unblock_host(const epee::net_utils::network_address &address)=0;
|
virtual bool unblock_host(const epee::net_utils::network_address &address)=0;
|
||||||
virtual std::map<std::string, time_t> get_blocked_hosts()=0;
|
virtual std::map<epee::net_utils::network_address, time_t> get_blocked_hosts()=0;
|
||||||
virtual bool add_host_fail(const epee::net_utils::network_address &address)=0;
|
virtual bool add_host_fail(const epee::net_utils::network_address &address)=0;
|
||||||
virtual void add_used_stripe_peer(const t_connection_context &context)=0;
|
virtual void add_used_stripe_peer(const t_connection_context &context)=0;
|
||||||
virtual void remove_used_stripe_peer(const t_connection_context &context)=0;
|
virtual void remove_used_stripe_peer(const t_connection_context &context)=0;
|
||||||
@ -112,9 +112,9 @@ namespace nodetool
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual std::map<std::string, time_t> get_blocked_hosts()
|
virtual std::map<epee::net_utils::network_address, time_t> get_blocked_hosts()
|
||||||
{
|
{
|
||||||
return std::map<std::string, time_t>();
|
return std::map<epee::net_utils::network_address, time_t>();
|
||||||
}
|
}
|
||||||
virtual bool add_host_fail(const epee::net_utils::network_address &address)
|
virtual bool add_host_fail(const epee::net_utils::network_address &address)
|
||||||
{
|
{
|
||||||
|
@ -1772,15 +1772,15 @@ namespace cryptonote
|
|||||||
PERF_TIMER(on_get_bans);
|
PERF_TIMER(on_get_bans);
|
||||||
|
|
||||||
auto now = time(nullptr);
|
auto now = time(nullptr);
|
||||||
std::map<std::string, time_t> blocked_hosts = m_p2p.get_blocked_hosts();
|
std::map<epee::net_utils::network_address, time_t> blocked_hosts = m_p2p.get_blocked_hosts();
|
||||||
for (std::map<std::string, time_t>::const_iterator i = blocked_hosts.begin(); i != blocked_hosts.end(); ++i)
|
for (std::map<epee::net_utils::network_address, time_t>::const_iterator i = blocked_hosts.begin(); i != blocked_hosts.end(); ++i)
|
||||||
{
|
{
|
||||||
if (i->second > now) {
|
if (i->second > now) {
|
||||||
COMMAND_RPC_GETBANS::ban b;
|
COMMAND_RPC_GETBANS::ban b;
|
||||||
b.host = i->first;
|
b.host = i->first.host_str();
|
||||||
b.ip = 0;
|
b.ip = 0;
|
||||||
uint32_t ip;
|
uint32_t ip;
|
||||||
if (epee::string_tools::get_ip_int32_from_string(ip, i->first))
|
if (epee::string_tools::get_ip_int32_from_string(ip, b.host))
|
||||||
b.ip = ip;
|
b.ip = ip;
|
||||||
b.seconds = i->second - now;
|
b.seconds = i->second - now;
|
||||||
res.bans.push_back(b);
|
res.bans.push_back(b);
|
||||||
|
Loading…
Reference in New Issue
Block a user