|
|
@ -174,7 +174,7 @@ namespace transport |
|
|
|
moreBytes = m_Socket.available(); |
|
|
|
moreBytes = m_Socket.available(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_Service.post (std::bind (&SSUServer::HandleReceivedPackets, this, packets, m_Sessions)); |
|
|
|
m_Service.post (std::bind (&SSUServer::HandleReceivedPackets, this, packets, &m_Sessions)); |
|
|
|
Receive (); |
|
|
|
Receive (); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -201,7 +201,7 @@ namespace transport |
|
|
|
moreBytes = m_SocketV6.available(); |
|
|
|
moreBytes = m_SocketV6.available(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
m_ServiceV6.post (std::bind (&SSUServer::HandleReceivedPackets, this, packets, m_SessionsV6)); |
|
|
|
m_ServiceV6.post (std::bind (&SSUServer::HandleReceivedPackets, this, packets, &m_SessionsV6)); |
|
|
|
ReceiveV6 (); |
|
|
|
ReceiveV6 (); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
@ -212,7 +212,7 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::HandleReceivedPackets (std::vector<SSUPacket *> packets, |
|
|
|
void SSUServer::HandleReceivedPackets (std::vector<SSUPacket *> packets, |
|
|
|
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSUSession> >& sessions) |
|
|
|
std::map<boost::asio::ip::udp::endpoint, std::shared_ptr<SSUSession> > * sessions) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::shared_ptr<SSUSession> session; |
|
|
|
std::shared_ptr<SSUSession> session; |
|
|
|
for (auto it1: packets) |
|
|
|
for (auto it1: packets) |
|
|
@ -223,14 +223,14 @@ namespace transport |
|
|
|
if (!session || session->GetRemoteEndpoint () != packet->from) // we received packet for other session than previous
|
|
|
|
if (!session || session->GetRemoteEndpoint () != packet->from) // we received packet for other session than previous
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (session) session->FlushData (); |
|
|
|
if (session) session->FlushData (); |
|
|
|
auto it = sessions.find (packet->from); |
|
|
|
auto it = sessions->find (packet->from); |
|
|
|
if (it != sessions.end ()) |
|
|
|
if (it != sessions->end ()) |
|
|
|
session = it->second; |
|
|
|
session = it->second; |
|
|
|
if (!session) |
|
|
|
if (!session) |
|
|
|
{ |
|
|
|
{ |
|
|
|
session = std::make_shared<SSUSession> (*this, packet->from); |
|
|
|
session = std::make_shared<SSUSession> (*this, packet->from); |
|
|
|
session->WaitForConnect (); |
|
|
|
session->WaitForConnect (); |
|
|
|
sessions[packet->from] = session; |
|
|
|
(*sessions)[packet->from] = session; |
|
|
|
LogPrint (eLogInfo, "New SSU session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created"); |
|
|
|
LogPrint (eLogInfo, "New SSU session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|