diff options
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r-- | src/p2p/net_node.inl | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index b5bfc2979..442c42517 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -203,15 +203,17 @@ namespace nodetool m_blocked_ips[addr] = time(nullptr) + seconds; // drop any connection to that IP - while (!m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) + std::list<boost::uuids::uuid> conns; + m_net_server.get_config_object().foreach_connection([&](const p2p_connection_context& cntxt) { if (cntxt.m_remote_ip == addr) { - drop_connection(cntxt); - return false; + conns.push_back(cntxt.m_connection_id); } return true; - })); + }); + for (const auto &c: conns) + m_net_server.get_config_object().close(c); LOG_PRINT_CYAN("IP " << epee::string_tools::get_ip_string_from_int32(addr) << " blocked.", LOG_LEVEL_0); return true; @@ -541,7 +543,7 @@ namespace nodetool } else if (result == 2) { LOG_PRINT_L0("IGD was found but reported as not connected."); } else if (result == 3) { - LOG_PRINT_L0("UPnP device was found but not recoginzed as IGD."); + LOG_PRINT_L0("UPnP device was found but not recognized as IGD."); } else { LOG_ERROR("UPNP_GetValidIGD returned an unknown result code."); } @@ -654,6 +656,7 @@ namespace nodetool template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::send_stop_signal() { + m_payload_handler.stop(); m_net_server.send_stop_signal(); LOG_PRINT_L0("[node] Stop signal sent"); return true; @@ -1242,6 +1245,16 @@ namespace nodetool } //----------------------------------------------------------------------------------- template<class t_payload_net_handler> + bool node_server<t_payload_net_handler>::relay_notify_to_list(int command, const std::string& data_buff, const std::list<boost::uuids::uuid> &connections) + { + BOOST_FOREACH(const auto& c_id, connections) + { + m_net_server.get_config_object().notify(command, data_buff, c_id); + } + return true; + } + //----------------------------------------------------------------------------------- + template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::relay_notify_to_all(int command, const std::string& data_buff, const epee::net_utils::connection_context_base& context) { std::list<boost::uuids::uuid> connections; @@ -1251,12 +1264,7 @@ namespace nodetool connections.push_back(cntxt.m_connection_id); return true; }); - - BOOST_FOREACH(const auto& c_id, connections) - { - m_net_server.get_config_object().notify(command, data_buff, c_id); - } - return true; + return relay_notify_to_list(command, data_buff, connections); } //----------------------------------------------------------------------------------- template<class t_payload_net_handler> @@ -1477,10 +1485,10 @@ namespace nodetool template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::log_peerlist() { - std::list<peerlist_entry> pl_wite; + std::list<peerlist_entry> pl_white; std::list<peerlist_entry> pl_gray; - m_peerlist.get_peerlist_full(pl_gray, pl_wite); - LOG_PRINT_L0(ENDL << "Peerlist white:" << ENDL << print_peerlist_to_string(pl_wite) << ENDL << "Peerlist gray:" << ENDL << print_peerlist_to_string(pl_gray) ); + m_peerlist.get_peerlist_full(pl_gray, pl_white); + LOG_PRINT_L0(ENDL << "Peerlist white:" << ENDL << print_peerlist_to_string(pl_white) << ENDL << "Peerlist gray:" << ENDL << print_peerlist_to_string(pl_gray) ); return true; } //----------------------------------------------------------------------------------- |