aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
authorjeffro256 <jeffro256@tutanota.com>2024-11-07 00:34:59 -0600
committerjeffro256 <jeffro256@tutanota.com>2024-12-13 13:37:39 -0600
commita1b545a2f7b2ac48d66e7fd846ca5093286525c7 (patch)
treec56fc42a90c9d0df1b8f57769f14306e3fc27117 /src/p2p
parent58a1d54a4f90a235616ede3f8ebae2b8dca41589 (diff)
downloadmonzero-core-a1b545a2f7b2ac48d66e7fd846ca5093286525c7.tar.gz
monzero-core-a1b545a2f7b2ac48d66e7fd846ca5093286525c7.tar.xz
monzero-core-a1b545a2f7b2ac48d66e7fd846ca5093286525c7.zip
p2p: allow comments in banlist files
In-line comments explicitly explaining banned hosts/subnets might help assuage fears of some good banlists' arbitaryiness.
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.inl10
1 files changed, 10 insertions, 0 deletions
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)
{