From e35bbb1e88e52f123c3e2f1d2bdbe2f704d0abe9 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Tue, 22 Dec 2020 02:11:52 +0000 Subject: ban lists may now include subnets --- src/p2p/net_node.inl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/p2p') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 128d17155..0bd971f92 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -481,13 +481,19 @@ namespace nodetool std::istringstream iss(banned_ips); for (std::string line; std::getline(iss, line); ) { + auto subnet = net::get_ipv4_subnet_address(line); + if (subnet) + { + block_subnet(*subnet, std::numeric_limits::max()); + continue; + } const expect parsed_addr = net::get_network_address(line, 0); - if (!parsed_addr) + if (parsed_addr) { - MERROR("Invalid IP address: " << line << " - " << parsed_addr.error()); + block_host(*parsed_addr, std::numeric_limits::max()); continue; } - block_host(*parsed_addr, std::numeric_limits::max()); + MERROR("Invalid IP address or IPv4 subnet: " << line); } } -- cgit v1.2.3