aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/net_node.inl
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r--src/p2p/net_node.inl28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index d7c48f991..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;
@@ -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>