mirror of
https://github.com/monero-project/monero.git
synced 2024-12-23 20:19:34 +00:00
ban lists may now include subnets
This commit is contained in:
parent
3bd6ed94d7
commit
56748e1d74
2 changed files with 20 additions and 8 deletions
|
@ -694,13 +694,19 @@ bool t_command_parser_executor::ban(const std::vector<std::string>& args)
|
||||||
std::ifstream ifs(ban_list_path.string());
|
std::ifstream ifs(ban_list_path.string());
|
||||||
for (std::string line; std::getline(ifs, line); )
|
for (std::string line; std::getline(ifs, line); )
|
||||||
{
|
{
|
||||||
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(line, 0);
|
auto subnet = net::get_ipv4_subnet_address(line);
|
||||||
if (!parsed_addr)
|
if (subnet)
|
||||||
{
|
{
|
||||||
std::cout << "Invalid IP address: " << line << " - " << parsed_addr.error() << std::endl;
|
ret &= m_executor.ban(subnet->str(), seconds);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(line, 0);
|
||||||
|
if (parsed_addr)
|
||||||
|
{
|
||||||
ret &= m_executor.ban(parsed_addr->host_str(), seconds);
|
ret &= m_executor.ban(parsed_addr->host_str(), seconds);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::cout << "Invalid IP address or IPv4 subnet: " << line << std::endl;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,13 +481,19 @@ namespace nodetool
|
||||||
std::istringstream iss(banned_ips);
|
std::istringstream iss(banned_ips);
|
||||||
for (std::string line; std::getline(iss, line); )
|
for (std::string line; std::getline(iss, line); )
|
||||||
{
|
{
|
||||||
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(line, 0);
|
auto subnet = net::get_ipv4_subnet_address(line);
|
||||||
if (!parsed_addr)
|
if (subnet)
|
||||||
{
|
{
|
||||||
MERROR("Invalid IP address: " << line << " - " << parsed_addr.error());
|
block_subnet(*subnet, std::numeric_limits<time_t>::max());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(line, 0);
|
||||||
|
if (parsed_addr)
|
||||||
|
{
|
||||||
block_host(*parsed_addr, std::numeric_limits<time_t>::max());
|
block_host(*parsed_addr, std::numeric_limits<time_t>::max());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MERROR("Invalid IP address or IPv4 subnet: " << line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue