From 1b8da90cbbcd61cf83bbfe0ddb1f55ed0bf871ed Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 12 Mar 2021 20:51:12 -0500 Subject: [PATCH] more precise compatibility check --- libi2pd/RouterInfo.cpp | 13 ++++++++++--- libi2pd/RouterInfo.h | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libi2pd/RouterInfo.cpp b/libi2pd/RouterInfo.cpp index 1d715d25..2157dd37 100644 --- a/libi2pd/RouterInfo.cpp +++ b/libi2pd/RouterInfo.cpp @@ -1131,9 +1131,16 @@ namespace data return (bool)GetAddress ( [commonTransports](std::shared_ptr address)->bool { - // TODO:check v4 and v6 separately based on caps - if ((commonTransports & (eNTCP2V4 | eNTCP2V6)) && address->IsPublishedNTCP2 ()) return true; - if ((commonTransports & (eSSUV4 | eSSUV6)) && address->IsReachableSSU ()) return true; + if (address->IsPublishedNTCP2 ()) + { + if ((commonTransports & eNTCP2V4) && address->IsV4 ()) return true; + if ((commonTransports & eNTCP2V6) && address->IsV6 ()) return true; + } + else if (address->IsReachableSSU ()) + { + if ((commonTransports & eSSUV4) && address->IsV4 ()) return true; + if ((commonTransports & eSSUV6) && address->IsV6 ()) return true; + } return false; }); } diff --git a/libi2pd/RouterInfo.h b/libi2pd/RouterInfo.h index 07aca2fc..93746e95 100644 --- a/libi2pd/RouterInfo.h +++ b/libi2pd/RouterInfo.h @@ -130,8 +130,8 @@ namespace data bool IsCompatible (const boost::asio::ip::address& other) const { - return (host.is_v4 () && other.is_v4 ()) || - (host.is_v6 () && other.is_v6 ()); + return (IsV4 () && other.is_v4 ()) || + (IsV6 () && other.is_v6 ()); } bool operator==(const Address& other) const