|
|
@ -211,22 +211,25 @@ namespace transport |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::HandleReceivedPackets (std::vector<SSUPacket *> packets) |
|
|
|
void SSUServer::HandleReceivedPackets (std::vector<SSUPacket *> packets) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
std::shared_ptr<SSUSession> session; |
|
|
|
for (auto it1: packets) |
|
|
|
for (auto it1: packets) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto packet = it1; |
|
|
|
auto packet = it1; |
|
|
|
std::shared_ptr<SSUSession> session; |
|
|
|
if (session && session->GetRemoteEndpoint () != packet->from) // we received packet for other session than previous
|
|
|
|
auto it = m_Sessions.find (packet->from); |
|
|
|
|
|
|
|
if (it != m_Sessions.end ()) |
|
|
|
|
|
|
|
session = it->second; |
|
|
|
|
|
|
|
if (!session) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
session = std::make_shared<SSUSession> (*this, packet->from); |
|
|
|
auto it = m_Sessions.find (packet->from); |
|
|
|
session->WaitForConnect (); |
|
|
|
if (it != m_Sessions.end ()) |
|
|
|
|
|
|
|
session = it->second; |
|
|
|
|
|
|
|
if (!session) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::unique_lock<std::mutex> l(m_SessionsMutex); |
|
|
|
session = std::make_shared<SSUSession> (*this, packet->from); |
|
|
|
m_Sessions[packet->from] = session; |
|
|
|
session->WaitForConnect (); |
|
|
|
} |
|
|
|
{ |
|
|
|
LogPrint ("New SSU session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created"); |
|
|
|
std::unique_lock<std::mutex> l(m_SessionsMutex); |
|
|
|
|
|
|
|
m_Sessions[packet->from] = session; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
LogPrint ("New SSU session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
session->ProcessNextMessage (packet->buf, packet->len, packet->from); |
|
|
|
session->ProcessNextMessage (packet->buf, packet->len, packet->from); |
|
|
|
delete packet; |
|
|
|
delete packet; |
|
|
|