diff --git a/libi2pd/RouterInfo.h b/libi2pd/RouterInfo.h index ef009265..e838f993 100644 --- a/libi2pd/RouterInfo.h +++ b/libi2pd/RouterInfo.h @@ -137,7 +137,7 @@ namespace data bool operator==(const Address& other) const { - return transportStyle == other.transportStyle && IsNTCP2 () == other.IsNTCP2 () && + return transportStyle == other.transportStyle && host == other.host && port == other.port; } @@ -149,7 +149,7 @@ namespace data bool IsNTCP2 () const { return transportStyle == eTransportNTCP; }; bool IsSSU2 () const { return transportStyle == eTransportSSU2; }; bool IsPublishedNTCP2 () const { return IsNTCP2 () && published; }; - bool IsReachableSSU () const { return (bool)ssu && (published || !ssu->introducers.empty ()); }; + bool IsReachableSSU () const { return (bool)ssu && (published || UsesIntroducer ()); }; bool UsesIntroducer () const { return (bool)ssu && !ssu->introducers.empty (); }; bool IsIntroducer () const { return caps & eSSUIntroducer; }; diff --git a/libi2pd/SSU2.cpp b/libi2pd/SSU2.cpp index 7e48ccfc..94f8eedb 100644 --- a/libi2pd/SSU2.cpp +++ b/libi2pd/SSU2.cpp @@ -1124,16 +1124,9 @@ namespace transport else { // we are Alice, message from Bob - boost::asio::ip::udp::endpoint ep; - if (ExtractEndpoint (buf + 12, buf[11], ep)) + // update Charlie's endpoint and connect + if (ExtractEndpoint (buf + 12, buf[11], it->second.first->m_RemoteEndpoint)) { - // update Charlie's address and connect - auto addr = std::make_shared (); - auto addr1 = it->second.first->m_Address; - addr->transportStyle = i2p::data::RouterInfo::eTransportSSU2; - addr->host = ep.address (); addr->port = ep.port (); - addr->s = addr1->s; addr->i = addr1->i; addr->caps = addr1->caps; - it->second.first->m_Address = addr; it->second.first->m_State = eSSU2SessionStateUnknown; it->second.first->Connect (); } @@ -1767,12 +1760,15 @@ namespace transport std::shared_ptr address) { if (router && address) + { + if (address->UsesIntroducer ()) return false; // not implemented yet GetService ().post ( [this, router, address]() { auto session = std::make_shared (*this, router, address); session->Connect (); - }); + }); + } else return false; return true; diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index 5e7099eb..007d3ffc 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -561,7 +561,7 @@ namespace transport } peer.numAttempts++; } - if (address && address->published) + if (address && address->IsReachableSSU ()) { if (m_SSU2Server->CreateSession (peer.router, address)) return true;