aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2021-01-20 15:18:39 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2021-01-21 01:41:31 +0000
commitb5667c9f6cca3e4145376de96f0cd1fa9e3ddcc3 (patch)
tree7ccc7bbe2f04383d75b31e288b9b7ed6a01280b1
parentMerge pull request #7295 (diff)
downloadmonero-b5667c9f6cca3e4145376de96f0cd1fa9e3ddcc3.tar.xz
p2p: allow CIDR notation in DNS blocklist
-rw-r--r--src/p2p/net_node.inl19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index f630a80b2..0f0b4ded4 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -2027,15 +2027,24 @@ namespace nodetool
boost::split(ips, record, boost::is_any_of(";"));
for (const auto &ip: ips)
{
+ if (ip.empty())
+ continue;
+ auto subnet = net::get_ipv4_subnet_address(ip);
+ if (subnet)
+ {
+ block_subnet(*subnet, DNS_BLOCKLIST_LIFETIME);
+ ++good;
+ continue;
+ }
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(ip, 0);
- if (!parsed_addr)
+ if (parsed_addr)
{
- MWARNING("Invalid IP address from DNS blocklist: " << ip << " - " << parsed_addr.error());
- ++bad;
+ block_host(*parsed_addr, DNS_BLOCKLIST_LIFETIME, true);
+ ++good;
continue;
}
- block_host(*parsed_addr, DNS_BLOCKLIST_LIFETIME, true);
- ++good;
+ MWARNING("Invalid IP address or subnet from DNS blocklist: " << ip << " - " << parsed_addr.error());
+ ++bad;
}
}
if (good > 0)