Merge pull request #7333

b5667c9 p2p: allow CIDR notation in DNS blocklist (moneromooo-monero)
This commit is contained in:
luigi1111 2021-02-16 11:45:38 -05:00
commit aa408d1c72
No known key found for this signature in database
GPG key ID: F4ACA0183641E010

View file

@ -2027,15 +2027,24 @@ namespace nodetool
boost::split(ips, record, boost::is_any_of(";"));
for (const auto &ip: ips)
{
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(ip, 0);
if (!parsed_addr)
if (ip.empty())
continue;
auto subnet = net::get_ipv4_subnet_address(ip);
if (subnet)
{
MWARNING("Invalid IP address from DNS blocklist: " << ip << " - " << parsed_addr.error());
++bad;
block_subnet(*subnet, DNS_BLOCKLIST_LIFETIME);
++good;
continue;
}
block_host(*parsed_addr, DNS_BLOCKLIST_LIFETIME, true);
++good;
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(ip, 0);
if (parsed_addr)
{
block_host(*parsed_addr, DNS_BLOCKLIST_LIFETIME, true);
++good;
continue;
}
MWARNING("Invalid IP address or subnet from DNS blocklist: " << ip << " - " << parsed_addr.error());
++bad;
}
}
if (good > 0)