|
|
|
@ -284,19 +284,28 @@ namespace transport
@@ -284,19 +284,28 @@ namespace transport
|
|
|
|
|
auto address = router->GetSSUAddress (!context.SupportsV6 ()); |
|
|
|
|
if (address) |
|
|
|
|
{ |
|
|
|
|
std::shared_ptr<SSUSession> session; |
|
|
|
|
boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port); |
|
|
|
|
auto& s = remoteEndpoint.address ().is_v6 () ? m_ServiceV6 : m_Service; |
|
|
|
|
s.post (std::bind (&SSUServer::CreateDirectSession, this, router, remoteEndpoint, peerTest)); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
LogPrint (eLogWarning, "Router ", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()), " doesn't have SSU address"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SSUServer::CreateDirectSession (std::shared_ptr<const i2p::data::RouterInfo> router, boost::asio::ip::udp::endpoint remoteEndpoint, bool peerTest) |
|
|
|
|
{ |
|
|
|
|
auto it = m_Sessions.find (remoteEndpoint); |
|
|
|
|
if (it != m_Sessions.end ()) |
|
|
|
|
{ |
|
|
|
|
session = it->second; |
|
|
|
|
auto session = it->second; |
|
|
|
|
if (peerTest && session->GetState () == eSessionStateEstablished) |
|
|
|
|
session->SendPeerTest (); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// otherwise create new session
|
|
|
|
|
session = std::make_shared<SSUSession> (*this, remoteEndpoint, router, peerTest); |
|
|
|
|
auto session = std::make_shared<SSUSession> (*this, remoteEndpoint, router, peerTest); |
|
|
|
|
{ |
|
|
|
|
std::unique_lock<std::mutex> l(m_SessionsMutex); |
|
|
|
|
m_Sessions[remoteEndpoint] = session; |
|
|
|
@ -307,10 +316,6 @@ namespace transport
@@ -307,10 +316,6 @@ namespace transport
|
|
|
|
|
session->Connect (); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
LogPrint (eLogWarning, "Router ", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()), " doesn't have SSU address"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SSUServer::CreateSessionThroughIntroducer (std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest) |
|
|
|
|
{ |
|
|
|
|