aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee
diff options
context:
space:
mode:
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)