forked from lthn/blockchain
added command for printing ip blacklist
This commit is contained in:
parent
a6538b5eca
commit
e4d9f1da59
3 changed files with 23 additions and 0 deletions
|
|
@ -48,6 +48,7 @@ public:
|
|||
m_cmd_binder.set_handler("print_tx_prun_info", boost::bind(&daemon_commands_handler::print_tx_prun_info, this, ph::_1), "Print tx prunning info");
|
||||
m_cmd_binder.set_handler("print_tx", boost::bind(&daemon_commands_handler::print_tx, this, ph::_1), "Print transaction, print_tx <transaction_hash>");
|
||||
m_cmd_binder.set_handler("print_asset_info", boost::bind(&daemon_commands_handler::print_asset_info, this, ph::_1), "Print information about the given asset by its id");
|
||||
m_cmd_binder.set_handler("print_blocked_ips", boost::bind(&daemon_commands_handler::print_blocked_ips, this, ph::_1), "Print ip address blacklists");
|
||||
m_cmd_binder.set_handler("start_mining", boost::bind(&daemon_commands_handler::start_mining, this, ph::_1), "Start mining for specified address, start_mining <addr> [threads=1]");
|
||||
m_cmd_binder.set_handler("stop_mining", boost::bind(&daemon_commands_handler::stop_mining, this, ph::_1), "Stop mining");
|
||||
m_cmd_binder.set_handler("print_pool", boost::bind(&daemon_commands_handler::print_pool, this, ph::_1), "Print transaction pool (long format)");
|
||||
|
|
@ -235,6 +236,20 @@ private:
|
|||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_blocked_ips(const std::vector<std::string>& args)
|
||||
{
|
||||
std::map<uint32_t, time_t> blocklist;
|
||||
m_srv.get_ip_block_list(blocklist);
|
||||
std::stringstream ss;
|
||||
ss << "BLOCKED IPS:" << ENDL;
|
||||
for (const auto& e : blocklist)
|
||||
{
|
||||
ss << string_tools::get_ip_string_from_int32(e.first) << ", time: " << std::put_time(std::localtime(&e.second), "%Y-%m-%d %H:%M:%S") << ENDL;
|
||||
}
|
||||
LOG_PRINT_L0(ss.str());
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_bc(const std::vector<std::string>& args)
|
||||
{
|
||||
if (!args.size())
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ namespace nodetool
|
|||
peerlist_manager& get_peerlist_manager(){return m_peerlist;}
|
||||
bool handle_maintainers_entry(const maintainers_entry& me);
|
||||
bool get_maintainers_info(maintainers_info_external& me);
|
||||
void get_ip_block_list(std::map<uint32_t, time_t>& blocklist);
|
||||
typedef COMMAND_REQUEST_STAT_INFO_T<typename t_payload_net_handler::stat_info> COMMAND_REQUEST_STAT_INFO;
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -448,6 +448,13 @@ namespace nodetool
|
|||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
void node_server<t_payload_net_handler>::get_ip_block_list(std::map<uint32_t, time_t>& blocklist)
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_blocked_ips_lock);
|
||||
blocklist = m_blocked_ips;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::on_maintainers_entry_update()
|
||||
{
|
||||
LOG_PRINT_CHANNEL_COLOR2(NULL, NULL, "Fresh maintainers info recieved(timestamp: " << m_maintainers_info_local.timestamp << ")", LOG_LEVEL_0, epee::log_space::console_color_magenta);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue