|
|
@ -28,6 +28,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "common/dns_utils.h"
|
|
|
|
#include "common/dns_utils.h"
|
|
|
|
#include "common/command_line.h"
|
|
|
|
#include "common/command_line.h"
|
|
|
|
|
|
|
|
#include "net/parse.h"
|
|
|
|
#include "daemon/command_parser_executor.h"
|
|
|
|
#include "daemon/command_parser_executor.h"
|
|
|
|
|
|
|
|
|
|
|
|
#undef MONERO_DEFAULT_LOG_CATEGORY
|
|
|
|
#undef MONERO_DEFAULT_LOG_CATEGORY
|
|
|
@ -657,7 +658,6 @@ bool t_command_parser_executor::ban(const std::vector<std::string>& args)
|
|
|
|
std::cout << "Invalid syntax: Expects one or two parameters. For more details, use the help command." << std::endl;
|
|
|
|
std::cout << "Invalid syntax: Expects one or two parameters. For more details, use the help command." << std::endl;
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::string ip = args[0];
|
|
|
|
|
|
|
|
time_t seconds = P2P_IP_BLOCKTIME;
|
|
|
|
time_t seconds = P2P_IP_BLOCKTIME;
|
|
|
|
if (args.size() > 1)
|
|
|
|
if (args.size() > 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -676,7 +676,45 @@ bool t_command_parser_executor::ban(const std::vector<std::string>& args)
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (boost::starts_with(args[0], "@"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const std::string ban_list = args[0].substr(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const boost::filesystem::path ban_list_path(ban_list);
|
|
|
|
|
|
|
|
boost::system::error_code ec;
|
|
|
|
|
|
|
|
if (!boost::filesystem::exists(ban_list_path, ec))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << "Can't find ban list file " + ban_list + " - " + ec.message() << std::endl;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ret = true;
|
|
|
|
|
|
|
|
std::ifstream ifs(ban_list_path.string());
|
|
|
|
|
|
|
|
for (std::string line; std::getline(ifs, line); )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const expect<epee::net_utils::network_address> parsed_addr = net::get_network_address(line, 0);
|
|
|
|
|
|
|
|
if (!parsed_addr)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << "Invalid IP address: " << line << " - " << parsed_addr.error() << std::endl;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ret &= m_executor.ban(parsed_addr->host_str(), seconds);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (const std::exception &e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << "Error loading ban list: " << e.what() << std::endl;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const std::string ip = args[0];
|
|
|
|
return m_executor.ban(ip, seconds);
|
|
|
|
return m_executor.ban(ip, seconds);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool t_command_parser_executor::unban(const std::vector<std::string>& args)
|
|
|
|
bool t_command_parser_executor::unban(const std::vector<std::string>& args)
|
|
|
|