diff options
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r-- | src/p2p/net_node.inl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 71a067ac5..9b6358dee 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1252,7 +1252,7 @@ namespace nodetool bool is_priority = is_priority_node(na); LOG_PRINT_CC_PRIORITY_NODE(is_priority, bool(con), "Connect failed to " << na.str() /*<< ", try " << try_count*/); - //m_peerlist.set_peer_unreachable(pe); + record_addr_failed(na); return false; } @@ -1267,6 +1267,7 @@ namespace nodetool << na.str() /*<< ", try " << try_count*/); zone.m_net_server.get_config_object().close(con->m_connection_id); + record_addr_failed(na); return false; } @@ -1317,6 +1318,7 @@ namespace nodetool bool is_priority = is_priority_node(na); LOG_PRINT_CC_PRIORITY_NODE(is_priority, p2p_connection_context{}, "Connect failed to " << na.str()); + record_addr_failed(na); return false; } @@ -1329,6 +1331,7 @@ namespace nodetool LOG_PRINT_CC_PRIORITY_NODE(is_priority, *con, "Failed to HANDSHAKE with peer " << na.str()); zone.m_net_server.get_config_object().close(con->m_connection_id); + record_addr_failed(na); return false; } @@ -1343,6 +1346,13 @@ namespace nodetool //----------------------------------------------------------------------------------- template<class t_payload_net_handler> + void node_server<t_payload_net_handler>::record_addr_failed(const epee::net_utils::network_address& addr) + { + CRITICAL_REGION_LOCAL(m_conn_fails_cache_lock); + m_conn_fails_cache[addr.host_str()] = time(NULL); + } + //----------------------------------------------------------------------------------- + template<class t_payload_net_handler> bool node_server<t_payload_net_handler>::is_addr_recently_failed(const epee::net_utils::network_address& addr) { CRITICAL_REGION_LOCAL(m_conn_fails_cache_lock); @@ -1908,7 +1918,7 @@ namespace nodetool LOG_DEBUG_CC(context, "REMOTE PEERLIST: remote peerlist size=" << peerlist_.size()); LOG_TRACE_CC(context, "REMOTE PEERLIST: " << ENDL << print_peerlist_to_string(peerlist_)); - return m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.merge_peerlist(peerlist_); + return m_network_zones.at(context.m_remote_address.get_zone()).m_peerlist.merge_peerlist(peerlist_, [this](const peerlist_entry &pe) { return !is_addr_recently_failed(pe.adr); }); } //----------------------------------------------------------------------------------- template<class t_payload_net_handler> |