diff options
author | Alexander Blair <snipa@jagtech.io> | 2020-12-26 13:59:51 -0800 |
---|---|---|
committer | Alexander Blair <snipa@jagtech.io> | 2020-12-26 13:59:51 -0800 |
commit | 0873f3193a345bee85fa56ce10d9d3387453741f (patch) | |
tree | f9f8000156fa94ee603c993ea73a72145bd55e7b /src/daemon | |
parent | Merge pull request #7174 (diff) | |
parent | ban lists may now include subnets (diff) | |
download | monero-0873f3193a345bee85fa56ce10d9d3387453741f.tar.xz |
Merge pull request #7181
e35bbb1e8 ban lists may now include subnets (moneromooo-monero)
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/command_parser_executor.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
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<std::string>& 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<epee::net_utils::network_address> 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; } |