aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2024-12-23 11:04:59 -0500
committerluigi1111 <luigi1111w@gmail.com>2024-12-23 11:04:59 -0500
commita6f21ca4bd88f87a9167b40ecb53374db969be60 (patch)
tree4ca84a7dbb787a55f17b82af1fd6615358e8b204 /src
parentf498b4d10d7e9a9a01b881c56dd671a312038729 (diff)
parenta1b545a2f7b2ac48d66e7fd846ca5093286525c7 (diff)
downloadmonzero-core-a6f21ca4bd88f87a9167b40ecb53374db969be60.tar.gz
monzero-core-a6f21ca4bd88f87a9167b40ecb53374db969be60.tar.xz
monzero-core-a6f21ca4bd88f87a9167b40ecb53374db969be60.zip
Merge pull request #9616
a1b545a p2p: allow comments in banlist files (jeffro256)
Diffstat (limited to 'src')
-rw-r--r--src/daemon/command_parser_executor.cpp10
-rw-r--r--src/p2p/net_node.inl10
2 files changed, 20 insertions, 0 deletions
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 20c906141..087a4e48b 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -696,6 +696,16 @@ bool t_command_parser_executor::ban(const std::vector<std::string>& args)
std::ifstream ifs(ban_list_path.string());
for (std::string line; std::getline(ifs, 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)
{
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)
{