From 1fb1d7e4e9f15d46c639b778cb4e0393cdda0dc1 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 13 Jul 2017 14:13:58 -0400 Subject: [PATCH] don't create SSU session if endpoint is not specified. Wait from RelayResponse --- libi2pd/SSU.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/libi2pd/SSU.cpp b/libi2pd/SSU.cpp index eabdd8c4..d8688442 100644 --- a/libi2pd/SSU.cpp +++ b/libi2pd/SSU.cpp @@ -433,7 +433,7 @@ namespace transport { boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port); auto it = m_Sessions.find (remoteEndpoint); - // check if session if presented alredy + // check if session is presented already if (it != m_Sessions.end ()) { auto session = it->second; @@ -480,18 +480,24 @@ namespace transport introducerSession = std::make_shared (*this, introducerEndpoint, router); m_Sessions[introducerEndpoint] = introducerSession; } - // create session - auto session = std::make_shared (*this, remoteEndpoint, router, peerTest); - m_Sessions[remoteEndpoint] = session; - // introduce - LogPrint (eLogInfo, "SSU: Introduce new session to [", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()), - "] through introducer ", introducer->iHost, ":", introducer->iPort); - session->WaitForIntroduction (); - if (i2p::context.GetRouterInfo ().UsesIntroducer ()) // if we are unreachable +#if BOOST_VERSION >= 104900 + if (!address->host.is_unspecified () && address->port) +#endif { - uint8_t buf[1]; - Send (buf, 0, remoteEndpoint); // send HolePunch - } + // create session + auto session = std::make_shared (*this, remoteEndpoint, router, peerTest); + m_Sessions[remoteEndpoint] = session; + + // introduce + LogPrint (eLogInfo, "SSU: Introduce new session to [", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()), + "] through introducer ", introducer->iHost, ":", introducer->iPort); + session->WaitForIntroduction (); + if (i2p::context.GetRouterInfo ().UsesIntroducer ()) // if we are unreachable + { + uint8_t buf[1]; + Send (buf, 0, remoteEndpoint); // send HolePunch + } + } introducerSession->Introduce (*introducer, router); } else