aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
authormoneromooo <moneromoo@nowhere.nowhere.nowhere>2020-12-03 13:22:52 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-12-06 15:57:40 +0000
commitff7fdf6db2534d243beefaea6a4c1be10b634a34 (patch)
treead051caba84c5ea7868ed5b6270c2855bee97227 /contrib/epee
parentkeep only the last seen node on a given host in the white list (diff)
downloadmonero-ff7fdf6db2534d243beefaea6a4c1be10b634a34.tar.xz
protocol: drop peers that don't reply to queries
Diffstat (limited to 'contrib/epee')
-rw-r--r--contrib/epee/src/net_utils_base.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/contrib/epee/src/net_utils_base.cpp b/contrib/epee/src/net_utils_base.cpp
index 6b2d27938..a2ca3d3d6 100644
--- a/contrib/epee/src/net_utils_base.cpp
+++ b/contrib/epee/src/net_utils_base.cpp
@@ -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)