diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h index 3de2d295..1b26fb73 100644 --- a/src/daemon/daemon_commands_handler.h +++ b/src/daemon/daemon_commands_handler.h @@ -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 "); 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 [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& args) + { + std::map 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& args) { if (!args.size()) diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index 9ec3cc17..38b5a5ab 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -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& blocklist); typedef COMMAND_REQUEST_STAT_INFO_T COMMAND_REQUEST_STAT_INFO; private: diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 70b906dc..fb1c4109 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -448,6 +448,13 @@ namespace nodetool } //----------------------------------------------------------------------------------- template + void node_server::get_ip_block_list(std::map& blocklist) + { + CRITICAL_REGION_LOCAL(m_blocked_ips_lock); + blocklist = m_blocked_ips; + } + //----------------------------------------------------------------------------------- + template bool node_server::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);