mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2025-07-08 19:01:43 +00:00
Merge pull request #2052
072102cf
abstracted nework addresses (moneromooo-monero)
This commit is contained in:
commit
a237f90c5b
18 changed files with 511 additions and 260 deletions
|
@ -736,12 +736,20 @@ namespace cryptonote
|
|||
|
||||
for (auto & entry : white_list)
|
||||
{
|
||||
res.white_list.emplace_back(entry.id, entry.adr.ip, entry.adr.port, entry.last_seen);
|
||||
if (entry.adr.type() == typeid(epee::net_utils::ipv4_network_address))
|
||||
res.white_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
|
||||
entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen);
|
||||
else
|
||||
res.white_list.emplace_back(entry.id, entry.adr.str(), entry.last_seen);
|
||||
}
|
||||
|
||||
for (auto & entry : gray_list)
|
||||
{
|
||||
res.gray_list.emplace_back(entry.id, entry.adr.ip, entry.adr.port, entry.last_seen);
|
||||
if (entry.adr.type() == typeid(epee::net_utils::ipv4_network_address))
|
||||
res.gray_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
|
||||
entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen);
|
||||
else
|
||||
res.gray_list.emplace_back(entry.id, entry.adr.str(), entry.last_seen);
|
||||
}
|
||||
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
|
@ -1308,12 +1316,16 @@ namespace cryptonote
|
|||
}
|
||||
|
||||
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)
|
||||
std::map<std::string, 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)
|
||||
{
|
||||
if (i->second > now) {
|
||||
COMMAND_RPC_GETBANS::ban b;
|
||||
b.ip = i->first;
|
||||
b.host = i->first;
|
||||
b.ip = 0;
|
||||
uint32_t ip;
|
||||
if (epee::string_tools::get_ip_int32_from_string(ip, i->first))
|
||||
b.ip = ip;
|
||||
b.seconds = i->second - now;
|
||||
res.bans.push_back(b);
|
||||
}
|
||||
|
@ -1334,10 +1346,24 @@ namespace cryptonote
|
|||
|
||||
for (auto i = req.bans.begin(); i != req.bans.end(); ++i)
|
||||
{
|
||||
if (i->ban)
|
||||
m_p2p.block_ip(i->ip, i->seconds);
|
||||
epee::net_utils::network_address na;
|
||||
if (!i->host.empty())
|
||||
{
|
||||
if (!epee::net_utils::create_network_address(na, i->host))
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_WRONG_PARAM;
|
||||
error_resp.message = "Unsupported host type";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
m_p2p.unblock_ip(i->ip);
|
||||
{
|
||||
na.reset(new epee::net_utils::ipv4_network_address(i->ip, 0));
|
||||
}
|
||||
if (i->ban)
|
||||
m_p2p.block_host(na, i->seconds);
|
||||
else
|
||||
m_p2p.unblock_host(na);
|
||||
}
|
||||
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue