From f407022fe6c4f5373fea360d7c4672a2cdbbc9d8 Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 4 Aug 2018 13:48:09 -0400 Subject: [PATCH] connect to NTCP2 address if presented --- libi2pd/Transports.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index e4a3021b..922625d2 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -404,14 +404,19 @@ namespace transport if (!peer.numAttempts) // NTCP { peer.numAttempts++; - auto address = peer.router->GetNTCPAddress (!context.SupportsV6 ()); - if (address && address->IsPublishedNTCP2 () && m_NTCP2Server) // NTCP2 have priority over NTCP if enabled + if (m_NTCP2Server) // we support NTCP2 { - auto s = std::make_shared (*m_NTCP2Server, peer.router); - m_NTCP2Server->Connect (address->host, address->port, s); - return true; - } - + // NTCP2 have priority over NTCP + auto address = peer.router->GetNTCP2Address (true, !context.SupportsV6 ()); // published only + if (address) + { + auto s = std::make_shared (*m_NTCP2Server, peer.router); + m_NTCP2Server->Connect (address->host, address->port, s); + return true; + } + } + // otherwise NTCP1 + auto address = peer.router->GetNTCPAddress (!context.SupportsV6 ()); if (address && m_NTCPServer) { #if BOOST_VERSION >= 104900