mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 13:23:29 +01:00
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)
This commit is contained in:
commit
b66d455536
@ -120,7 +120,7 @@ namespace nodetool
|
|||||||
void delete_connections(size_t count);
|
void delete_connections(size_t count);
|
||||||
virtual bool block_ip(uint32_t adress, time_t seconds = P2P_IP_BLOCKTIME);
|
virtual bool block_ip(uint32_t adress, time_t seconds = P2P_IP_BLOCKTIME);
|
||||||
virtual bool unblock_ip(uint32_t address);
|
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:
|
private:
|
||||||
const std::vector<std::string> m_seed_nodes_list =
|
const std::vector<std::string> m_seed_nodes_list =
|
||||||
{ "seeds.moneroseeds.se"
|
{ "seeds.moneroseeds.se"
|
||||||
|
@ -52,7 +52,7 @@ namespace nodetool
|
|||||||
virtual void for_each_connection(std::function<bool(t_connection_context&, peerid_type)> f)=0;
|
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 block_ip(uint32_t adress, time_t seconds = 0)=0;
|
||||||
virtual bool unblock_ip(uint32_t adress)=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;
|
virtual bool add_ip_fail(uint32_t adress)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ namespace nodetool
|
|||||||
{
|
{
|
||||||
return true;
|
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>();
|
return std::map<uint32_t, time_t>();
|
||||||
}
|
}
|
||||||
|
@ -950,13 +950,16 @@ namespace cryptonote
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto now = time(nullptr);
|
||||||
std::map<uint32_t, time_t> blocked_ips = m_p2p.get_blocked_ips();
|
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)
|
for (std::map<uint32_t, time_t>::const_iterator i = blocked_ips.begin(); i != blocked_ips.end(); ++i)
|
||||||
{
|
{
|
||||||
COMMAND_RPC_GETBANS::ban b;
|
if (i->second > now) {
|
||||||
b.ip = i->first;
|
COMMAND_RPC_GETBANS::ban b;
|
||||||
b.seconds = i->second;
|
b.ip = i->first;
|
||||||
res.bans.push_back(b);
|
b.seconds = i->second - now;
|
||||||
|
res.bans.push_back(b);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status = CORE_RPC_STATUS_OK;
|
res.status = CORE_RPC_STATUS_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user