From a1b545a2f7b2ac48d66e7fd846ca5093286525c7 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Thu, 7 Nov 2024 00:34:59 -0600 Subject: p2p: allow comments in banlist files In-line comments explicitly explaining banned hosts/subnets might help assuage fears of some good banlists' arbitaryiness. --- src/p2p/net_node.inl | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/p2p') diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 71f5393e8..08cd70cae 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -531,6 +531,16 @@ namespace nodetool std::istringstream iss(banned_ips); for (std::string line; std::getline(iss, line); ) { + // ignore comments after '#' character + const size_t pound_idx = line.find('#'); + if (pound_idx != std::string::npos) + line.resize(pound_idx); + + // trim whitespace and ignore empty lines + boost::trim(line); + if (line.empty()) + continue; + auto subnet = net::get_ipv4_subnet_address(line); if (subnet) { -- cgit v1.2.3