mirror of
https://github.com/monero-project/monero.git
synced 2025-08-02 08:06:11 -04:00
protocol: drop peers that don't reply to queries
This commit is contained in:
parent
89e984d93b
commit
ff7fdf6db2
4 changed files with 43 additions and 19 deletions
|
@ -94,11 +94,10 @@ namespace epee { namespace net_utils
|
|||
network_address::interface const* const other_self = other.self.get();
|
||||
if (self_ == other_self) return true;
|
||||
if (!self_ || !other_self) return false;
|
||||
const bool this_is_4 = get_type_id() == epee::net_utils::ipv4_network_address::get_type_id();
|
||||
const bool this_is_6 = get_type_id() == epee::net_utils::ipv6_network_address::get_type_id();
|
||||
const bool other_is_4 = other.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id();
|
||||
const bool other_is_6 = other.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id();
|
||||
if (this_is_4 && other_is_6)
|
||||
if (typeid(*self_) == typeid(*other_self))
|
||||
return self_->is_same_host(*other_self);
|
||||
const auto this_id = get_type_id();
|
||||
if (this_id == ipv4_network_address::get_type_id() && other.get_type_id() == ipv6_network_address::get_type_id())
|
||||
{
|
||||
const boost::asio::ip::address_v6 &actual_ip = other.as<const epee::net_utils::ipv6_network_address>().ip();
|
||||
if (actual_ip.is_v4_mapped())
|
||||
|
@ -107,7 +106,7 @@ namespace epee { namespace net_utils
|
|||
return is_same_host(ipv4_network_address(v4ip, 0));
|
||||
}
|
||||
}
|
||||
else if (this_is_6 && other_is_4)
|
||||
else if (this_id == ipv6_network_address::get_type_id() && other.get_type_id() == ipv4_network_address::get_type_id())
|
||||
{
|
||||
const boost::asio::ip::address_v6 &actual_ip = this->as<const epee::net_utils::ipv6_network_address>().ip();
|
||||
if (actual_ip.is_v4_mapped())
|
||||
|
@ -116,8 +115,7 @@ namespace epee { namespace net_utils
|
|||
return other.is_same_host(ipv4_network_address(v4ip, 0));
|
||||
}
|
||||
}
|
||||
if (typeid(*self_) != typeid(*other_self)) return false;
|
||||
return self_->is_same_host(*other_self);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string print_connection_context(const connection_context_base& ctx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue