mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-26 17:32:33 +00:00
Merge pull request #6295
bcae95a2
p2p: do not add recently failed addresses to the peerlist (moneromooo-monero)
This commit is contained in:
commit
3ed5e7ce9f
3 changed files with 17 additions and 7 deletions
|
@ -380,7 +380,7 @@ namespace nodetool
|
||||||
bool try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback &cb);
|
bool try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback &cb);
|
||||||
bool try_get_support_flags(const p2p_connection_context& context, std::function<void(p2p_connection_context&, const uint32_t&)> f);
|
bool try_get_support_flags(const p2p_connection_context& context, std::function<void(p2p_connection_context&, const uint32_t&)> f);
|
||||||
bool make_expected_connections_count(network_zone& zone, PeerType peer_type, size_t expected_connections);
|
bool make_expected_connections_count(network_zone& zone, PeerType peer_type, size_t expected_connections);
|
||||||
void cache_connect_fail_info(const epee::net_utils::network_address& addr);
|
void record_addr_failed(const epee::net_utils::network_address& addr);
|
||||||
bool is_addr_recently_failed(const epee::net_utils::network_address& addr);
|
bool is_addr_recently_failed(const epee::net_utils::network_address& addr);
|
||||||
bool is_priority_node(const epee::net_utils::network_address& na);
|
bool is_priority_node(const epee::net_utils::network_address& na);
|
||||||
std::set<std::string> get_seed_nodes(cryptonote::network_type nettype) const;
|
std::set<std::string> get_seed_nodes(cryptonote::network_type nettype) const;
|
||||||
|
|
|
@ -1252,7 +1252,7 @@ namespace nodetool
|
||||||
bool is_priority = is_priority_node(na);
|
bool is_priority = is_priority_node(na);
|
||||||
LOG_PRINT_CC_PRIORITY_NODE(is_priority, bool(con), "Connect failed to " << na.str()
|
LOG_PRINT_CC_PRIORITY_NODE(is_priority, bool(con), "Connect failed to " << na.str()
|
||||||
/*<< ", try " << try_count*/);
|
/*<< ", try " << try_count*/);
|
||||||
//m_peerlist.set_peer_unreachable(pe);
|
record_addr_failed(na);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,6 +1267,7 @@ namespace nodetool
|
||||||
<< na.str()
|
<< na.str()
|
||||||
/*<< ", try " << try_count*/);
|
/*<< ", try " << try_count*/);
|
||||||
zone.m_net_server.get_config_object().close(con->m_connection_id);
|
zone.m_net_server.get_config_object().close(con->m_connection_id);
|
||||||
|
record_addr_failed(na);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1317,6 +1318,7 @@ namespace nodetool
|
||||||
bool is_priority = is_priority_node(na);
|
bool is_priority = is_priority_node(na);
|
||||||
|
|
||||||
LOG_PRINT_CC_PRIORITY_NODE(is_priority, p2p_connection_context{}, "Connect failed to " << na.str());
|
LOG_PRINT_CC_PRIORITY_NODE(is_priority, p2p_connection_context{}, "Connect failed to " << na.str());
|
||||||
|
record_addr_failed(na);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1329,6 +1331,7 @@ namespace nodetool
|
||||||
|
|
||||||
LOG_PRINT_CC_PRIORITY_NODE(is_priority, *con, "Failed to HANDSHAKE with peer " << na.str());
|
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);
|
zone.m_net_server.get_config_object().close(con->m_connection_id);
|
||||||
|
record_addr_failed(na);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1341,6 +1344,13 @@ namespace nodetool
|
||||||
|
|
||||||
#undef LOG_PRINT_CC_PRIORITY_NODE
|
#undef LOG_PRINT_CC_PRIORITY_NODE
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
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>
|
template<class t_payload_net_handler>
|
||||||
bool node_server<t_payload_net_handler>::is_addr_recently_failed(const epee::net_utils::network_address& addr)
|
bool node_server<t_payload_net_handler>::is_addr_recently_failed(const epee::net_utils::network_address& addr)
|
||||||
|
@ -1908,7 +1918,7 @@ namespace nodetool
|
||||||
|
|
||||||
LOG_DEBUG_CC(context, "REMOTE PEERLIST: remote peerlist size=" << peerlist_.size());
|
LOG_DEBUG_CC(context, "REMOTE PEERLIST: remote peerlist size=" << peerlist_.size());
|
||||||
LOG_TRACE_CC(context, "REMOTE PEERLIST: " << ENDL << print_peerlist_to_string(peerlist_));
|
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>
|
template<class t_payload_net_handler>
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace nodetool
|
||||||
bool init(peerlist_types&& peers, bool allow_local_ip);
|
bool init(peerlist_types&& peers, bool allow_local_ip);
|
||||||
size_t get_white_peers_count(){CRITICAL_REGION_LOCAL(m_peerlist_lock); return m_peers_white.size();}
|
size_t get_white_peers_count(){CRITICAL_REGION_LOCAL(m_peerlist_lock); return m_peers_white.size();}
|
||||||
size_t get_gray_peers_count(){CRITICAL_REGION_LOCAL(m_peerlist_lock); return m_peers_gray.size();}
|
size_t get_gray_peers_count(){CRITICAL_REGION_LOCAL(m_peerlist_lock); return m_peers_gray.size();}
|
||||||
bool merge_peerlist(const std::vector<peerlist_entry>& outer_bs);
|
bool merge_peerlist(const std::vector<peerlist_entry>& outer_bs, const std::function<bool(const peerlist_entry&)> &f = NULL);
|
||||||
bool get_peerlist_head(std::vector<peerlist_entry>& bs_head, bool anonymize, uint32_t depth = P2P_DEFAULT_PEERS_IN_HANDSHAKE);
|
bool get_peerlist_head(std::vector<peerlist_entry>& bs_head, bool anonymize, uint32_t depth = P2P_DEFAULT_PEERS_IN_HANDSHAKE);
|
||||||
void get_peerlist(std::vector<peerlist_entry>& pl_gray, std::vector<peerlist_entry>& pl_white);
|
void get_peerlist(std::vector<peerlist_entry>& pl_gray, std::vector<peerlist_entry>& pl_white);
|
||||||
void get_peerlist(peerlist_types& peers);
|
void get_peerlist(peerlist_types& peers);
|
||||||
|
@ -113,7 +113,6 @@ namespace nodetool
|
||||||
bool append_with_peer_gray(const peerlist_entry& pr);
|
bool append_with_peer_gray(const peerlist_entry& pr);
|
||||||
bool append_with_peer_anchor(const anchor_peerlist_entry& ple);
|
bool append_with_peer_anchor(const anchor_peerlist_entry& ple);
|
||||||
bool set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed, uint16_t rpc_port, uint32_t rpc_credits_per_hash);
|
bool set_peer_just_seen(peerid_type peer, const epee::net_utils::network_address& addr, uint32_t pruning_seed, uint16_t rpc_port, uint32_t rpc_credits_per_hash);
|
||||||
bool set_peer_unreachable(const peerlist_entry& pr);
|
|
||||||
bool is_host_allowed(const epee::net_utils::network_address &address);
|
bool is_host_allowed(const epee::net_utils::network_address &address);
|
||||||
bool get_random_gray_peer(peerlist_entry& pe);
|
bool get_random_gray_peer(peerlist_entry& pe);
|
||||||
bool remove_from_peer_gray(const peerlist_entry& pe);
|
bool remove_from_peer_gray(const peerlist_entry& pe);
|
||||||
|
@ -214,12 +213,13 @@ namespace nodetool
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
inline
|
inline
|
||||||
bool peerlist_manager::merge_peerlist(const std::vector<peerlist_entry>& outer_bs)
|
bool peerlist_manager::merge_peerlist(const std::vector<peerlist_entry>& outer_bs, const std::function<bool(const peerlist_entry&)> &f)
|
||||||
{
|
{
|
||||||
CRITICAL_REGION_LOCAL(m_peerlist_lock);
|
CRITICAL_REGION_LOCAL(m_peerlist_lock);
|
||||||
for(const peerlist_entry& be: outer_bs)
|
for(const peerlist_entry& be: outer_bs)
|
||||||
{
|
{
|
||||||
append_with_peer_gray(be);
|
if (!f || f(be))
|
||||||
|
append_with_peer_gray(be);
|
||||||
}
|
}
|
||||||
// delete extra elements
|
// delete extra elements
|
||||||
trim_gray_peerlist();
|
trim_gray_peerlist();
|
||||||
|
|
Loading…
Reference in a new issue