|
|
@ -445,7 +445,7 @@ namespace transport |
|
|
|
if (router && address) |
|
|
|
if (router && address) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (router->UsesIntroducer ()) |
|
|
|
if (router->UsesIntroducer ()) |
|
|
|
m_Service.post (std::bind (&SSUServer::CreateSessionThroughIntroducer, this, router, peerTest)); // always V4 thread
|
|
|
|
m_Service.post (std::bind (&SSUServer::CreateSessionThroughIntroducer, this, router, address, peerTest)); // always V4 thread
|
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port); |
|
|
|
boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port); |
|
|
@ -477,12 +477,12 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::CreateSessionThroughIntroducer (std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest) |
|
|
|
void SSUServer::CreateSessionThroughIntroducer (std::shared_ptr<const i2p::data::RouterInfo> router, |
|
|
|
|
|
|
|
std::shared_ptr<const i2p::data::RouterInfo::Address> address, bool peerTest) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (router && router->UsesIntroducer ()) |
|
|
|
if (router && router->UsesIntroducer () && address) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto address = router->GetSSUAddress (true); // v4 only for now
|
|
|
|
if (!address->host.is_unspecified () && address->port) |
|
|
|
if (address) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port); |
|
|
|
boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port); |
|
|
|
auto it = m_Sessions.find (remoteEndpoint); |
|
|
|
auto it = m_Sessions.find (remoteEndpoint); |
|
|
@ -494,6 +494,7 @@ namespace transport |
|
|
|
session->SendPeerTest (); |
|
|
|
session->SendPeerTest (); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
// create new session
|
|
|
|
// create new session
|
|
|
|
int numIntroducers = address->ssu->introducers.size (); |
|
|
|
int numIntroducers = address->ssu->introducers.size (); |
|
|
|
if (numIntroducers > 0) |
|
|
|
if (numIntroducers > 0) |
|
|
@ -510,7 +511,7 @@ namespace transport |
|
|
|
if (ep.address ().is_v4 ()) // ipv4 only
|
|
|
|
if (ep.address ().is_v4 ()) // ipv4 only
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!introducer) introducer = intr; // we pick first one for now
|
|
|
|
if (!introducer) introducer = intr; // we pick first one for now
|
|
|
|
it = m_Sessions.find (ep); |
|
|
|
auto it = m_Sessions.find (ep); |
|
|
|
if (it != m_Sessions.end ()) |
|
|
|
if (it != m_Sessions.end ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
introducerSession = it->second; |
|
|
|
introducerSession = it->second; |
|
|
@ -533,11 +534,10 @@ namespace transport |
|
|
|
introducerSession = std::make_shared<SSUSession> (*this, introducerEndpoint, router); |
|
|
|
introducerSession = std::make_shared<SSUSession> (*this, introducerEndpoint, router); |
|
|
|
m_Sessions[introducerEndpoint] = introducerSession; |
|
|
|
m_Sessions[introducerEndpoint] = introducerSession; |
|
|
|
} |
|
|
|
} |
|
|
|
#if BOOST_VERSION >= 104900 |
|
|
|
|
|
|
|
if (!address->host.is_unspecified () && address->port) |
|
|
|
if (!address->host.is_unspecified () && address->port) |
|
|
|
#endif |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
// create session
|
|
|
|
// create session
|
|
|
|
|
|
|
|
boost::asio::ip::udp::endpoint remoteEndpoint (address->host, address->port); |
|
|
|
auto session = std::make_shared<SSUSession> (*this, remoteEndpoint, router, peerTest); |
|
|
|
auto session = std::make_shared<SSUSession> (*this, remoteEndpoint, router, peerTest); |
|
|
|
m_Sessions[remoteEndpoint] = session; |
|
|
|
m_Sessions[remoteEndpoint] = session; |
|
|
|
|
|
|
|
|
|
|
@ -556,9 +556,6 @@ namespace transport |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogWarning, "SSU: Can't connect to unreachable router and no introducers present"); |
|
|
|
LogPrint (eLogWarning, "SSU: Can't connect to unreachable router and no introducers present"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "SSU: Router ", i2p::data::GetIdentHashAbbreviation (router->GetIdentHash ()), " doesn't have SSU address"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::DeleteSession (std::shared_ptr<SSUSession> session) |
|
|
|
void SSUServer::DeleteSession (std::shared_ptr<SSUSession> session) |
|
|
|