|
|
@ -620,13 +620,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); )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
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);
|
|
|
|
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;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret &= m_executor.ban(parsed_addr->host_str(), seconds);
|
|
|
|
std::cout << "Invalid IP address or IPv4 subnet: " << line << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|