|
|
@ -340,21 +340,30 @@ namespace transport |
|
|
|
// we might have a session to introducer already
|
|
|
|
// we might have a session to introducer already
|
|
|
|
for (int i = 0; i < numIntroducers; i++) |
|
|
|
for (int i = 0; i < numIntroducers; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
introducer = &(address->introducers[i]); |
|
|
|
auto intr = &(address->introducers[i]); |
|
|
|
it = m_Sessions.find (boost::asio::ip::udp::endpoint (introducer->iHost, introducer->iPort)); |
|
|
|
boost::asio::ip::udp::endpoint ep (intr->iHost, intr->iPort); |
|
|
|
if (it != m_Sessions.end ()) |
|
|
|
if (ep.address ().is_v4 ()) // ipv4 only
|
|
|
|
{ |
|
|
|
{ |
|
|
|
introducerSession = it->second; |
|
|
|
if (!introducer) introducer = intr; // we pick first one for now
|
|
|
|
break; |
|
|
|
it = m_Sessions.find (ep); |
|
|
|
} |
|
|
|
if (it != m_Sessions.end ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
introducerSession = it->second; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!introducer) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "Can't connect to unreachable router. No ipv4 introducers presented"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (introducerSession) // session found
|
|
|
|
if (introducerSession) // session found
|
|
|
|
LogPrint ("Session to introducer already exists"); |
|
|
|
LogPrint (eLogInfo, "Session to introducer already exists"); |
|
|
|
else // create new
|
|
|
|
else // create new
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Creating new session to introducer"); |
|
|
|
LogPrint (eLogInfo, "Creating new session to introducer"); |
|
|
|
introducer = &(address->introducers[0]); // TODO:
|
|
|
|
|
|
|
|
boost::asio::ip::udp::endpoint introducerEndpoint (introducer->iHost, introducer->iPort); |
|
|
|
boost::asio::ip::udp::endpoint introducerEndpoint (introducer->iHost, introducer->iPort); |
|
|
|
introducerSession = std::make_shared<SSUSession> (*this, introducerEndpoint, router); |
|
|
|
introducerSession = std::make_shared<SSUSession> (*this, introducerEndpoint, router); |
|
|
|
m_Sessions[introducerEndpoint] = introducerSession; |
|
|
|
m_Sessions[introducerEndpoint] = introducerSession; |
|
|
|