diff --git a/SSU.cpp b/SSU.cpp index d4b2b05d..41946c0a 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -272,7 +272,7 @@ namespace transport return nullptr; } - std::shared_ptr SSUServer::GetSession (std::shared_ptr router, bool peerTest) + void SSUServer::CreateSession (std::shared_ptr router, bool peerTest) { std::shared_ptr session; if (router) @@ -350,7 +350,6 @@ namespace transport LogPrint (eLogWarning, "Can't connect to unreachable router. No introducers presented"); std::unique_lock l(m_SessionsMutex); m_Sessions.erase (remoteEndpoint); - session.reset (); } } } @@ -358,7 +357,6 @@ namespace transport else LogPrint (eLogWarning, "Router ", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()), " doesn't have SSU address"); } - return session; } void SSUServer::DeleteSession (std::shared_ptr session) @@ -491,7 +489,7 @@ namespace transport { auto introducer = i2p::data::netdb.GetRandomIntroducer (); if (introducer) - GetSession (introducer); + CreateSession (introducer); } ScheduleIntroducersUpdateTimer (); } diff --git a/SSU.h b/SSU.h index db9d57eb..bf660523 100644 --- a/SSU.h +++ b/SSU.h @@ -40,7 +40,7 @@ namespace transport ~SSUServer (); void Start (); void Stop (); - std::shared_ptr GetSession (std::shared_ptr router, bool peerTest = false); + void CreateSession (std::shared_ptr router, bool peerTest = false); std::shared_ptr FindSession (std::shared_ptr router) const; std::shared_ptr FindSession (const boost::asio::ip::udp::endpoint& e) const; std::shared_ptr GetRandomEstablishedSession (std::shared_ptr excluded); diff --git a/Transports.cpp b/Transports.cpp index 635c5e04..1b74093c 100644 --- a/Transports.cpp +++ b/Transports.cpp @@ -290,8 +290,11 @@ namespace transport peer.numAttempts++; if (m_SSUServer) { - if (m_SSUServer->GetSession (peer.router)) + if (peer.router->IsSSU (!context.SupportsV6 ())) + { + m_SSUServer->CreateSession (peer.router); return true; + } } } LogPrint (eLogError, "No NTCP and SSU addresses available"); @@ -389,14 +392,14 @@ namespace transport for (int i = 0; i < 5; i++) { auto router = i2p::data::netdb.GetRandomPeerTestRouter (); - if (router && router->IsSSU ()) - m_SSUServer->GetSession (router, true); // peer test + if (router && router->IsSSU (!context.SupportsV6 ())) + m_SSUServer->CreateSession (router, true); // peer test else { // if not peer test capable routers found pick any router = i2p::data::netdb.GetRandomRouter (); if (router && router->IsSSU ()) - m_SSUServer->GetSession (router); // no peer test + m_SSUServer->CreateSession (router); // no peer test } } } @@ -412,14 +415,14 @@ namespace transport for (int i = 0; i < 5; i++) { auto router = i2p::data::netdb.GetRandomPeerTestRouter (); - if (router && router->IsSSU ()) + if (router && router->IsSSU (!context.SupportsV6 ())) { if (!statusChanged) { statusChanged = true; i2p::context.SetStatus (eRouterStatusTesting); // first time only } - m_SSUServer->GetSession (router, true); // peer test + m_SSUServer->CreateSession (router, true); // peer test } } }