aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2021-02-16 11:45:38 -0500
committerluigi1111 <luigi1111w@gmail.com>2021-02-16 11:45:38 -0500
commitaa408d1c7269c48debece41cc9d3581520813145 (patch)
tree8813d13fb02a90a9b5ee2d43bcbde90830a26270 /src
parentMerge pull request #7309 (diff)
parentp2p: allow CIDR notation in DNS blocklist (diff)
downloadmonero-aa408d1c7269c48debece41cc9d3581520813145.tar.xz
Merge pull request #7333
b5667c9 p2p: allow CIDR notation in DNS blocklist (moneromooo-monero)
Diffstat (limited to 'src')
-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)