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/daemon/command_parser_executor.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/daemon') diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index 6695c3ecd..ab1a8881e 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -620,13 +620,19 @@ bool t_command_parser_executor::ban(const std::vector& args) std::ifstream ifs(ban_list_path.string()); for (std::string line; std::getline(ifs, line); ) { + auto subnet = net::get_ipv4_subnet_address(line); + if (subnet) + { + ret &= m_executor.ban(subnet->str(), seconds); + continue; + } const expect parsed_addr = net::get_network_address(line, 0); - if (!parsed_addr) + if (parsed_addr) { - std::cout << "Invalid IP address: " << line << " - " << parsed_addr.error() << std::endl; + ret &= m_executor.ban(parsed_addr->host_str(), seconds); continue; } - ret &= m_executor.ban(parsed_addr->host_str(), seconds); + std::cout << "Invalid IP address or IPv4 subnet: " << line << std::endl; } return ret; } -- cgit v1.2.3