|
|
@ -187,14 +187,14 @@ namespace transport |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::Receive () |
|
|
|
void SSUServer::Receive () |
|
|
|
{ |
|
|
|
{ |
|
|
|
SSUPacket * packet = new SSUPacket (); |
|
|
|
SSUPacket * packet = m_Packets.AcquireMt (); |
|
|
|
m_Socket.async_receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V4), packet->from, |
|
|
|
m_Socket.async_receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V4), packet->from, |
|
|
|
std::bind (&SSUServer::HandleReceivedFrom, this, std::placeholders::_1, std::placeholders::_2, packet)); |
|
|
|
std::bind (&SSUServer::HandleReceivedFrom, this, std::placeholders::_1, std::placeholders::_2, packet)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUServer::ReceiveV6 () |
|
|
|
void SSUServer::ReceiveV6 () |
|
|
|
{ |
|
|
|
{ |
|
|
|
SSUPacket * packet = new SSUPacket (); |
|
|
|
SSUPacket * packet = m_Packets.AcquireMt (); |
|
|
|
m_SocketV6.async_receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V6), packet->from, |
|
|
|
m_SocketV6.async_receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V6), packet->from, |
|
|
|
std::bind (&SSUServer::HandleReceivedFromV6, this, std::placeholders::_1, std::placeholders::_2, packet)); |
|
|
|
std::bind (&SSUServer::HandleReceivedFromV6, this, std::placeholders::_1, std::placeholders::_2, packet)); |
|
|
|
} |
|
|
|
} |
|
|
@ -213,7 +213,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (moreBytes && packets.size () < 25) |
|
|
|
while (moreBytes && packets.size () < 25) |
|
|
|
{ |
|
|
|
{ |
|
|
|
packet = new SSUPacket (); |
|
|
|
packet = m_Packets.AcquireMt (); |
|
|
|
packet->len = m_Socket.receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V4), packet->from, 0, ec); |
|
|
|
packet->len = m_Socket.receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V4), packet->from, 0, ec); |
|
|
|
if (!ec) |
|
|
|
if (!ec) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -224,7 +224,7 @@ namespace transport |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "SSU: receive_from error: ", ec.message ()); |
|
|
|
LogPrint (eLogError, "SSU: receive_from error: ", ec.message ()); |
|
|
|
delete packet; |
|
|
|
m_Packets.ReleaseMt (packet); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -260,7 +260,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
while (moreBytes && packets.size () < 25) |
|
|
|
while (moreBytes && packets.size () < 25) |
|
|
|
{ |
|
|
|
{ |
|
|
|
packet = new SSUPacket (); |
|
|
|
packet = m_Packets.AcquireMt (); |
|
|
|
packet->len = m_SocketV6.receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V6), packet->from, 0, ec); |
|
|
|
packet->len = m_SocketV6.receive_from (boost::asio::buffer (packet->buf, SSU_MTU_V6), packet->from, 0, ec); |
|
|
|
if (!ec) |
|
|
|
if (!ec) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -271,7 +271,7 @@ namespace transport |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "SSU: v6 receive_from error: ", ec.message ()); |
|
|
|
LogPrint (eLogError, "SSU: v6 receive_from error: ", ec.message ()); |
|
|
|
delete packet; |
|
|
|
m_Packets.ReleaseMt (packet); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -282,7 +282,7 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
delete packet; |
|
|
|
m_Packets.ReleaseMt (packet); |
|
|
|
if (ecode != boost::asio::error::operation_aborted) |
|
|
|
if (ecode != boost::asio::error::operation_aborted) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "SSU: v6 receive error: ", ecode.message ()); |
|
|
|
LogPrint (eLogError, "SSU: v6 receive error: ", ecode.message ()); |
|
|
@ -323,8 +323,8 @@ namespace transport |
|
|
|
if (session) session->FlushData (); |
|
|
|
if (session) session->FlushData (); |
|
|
|
session = nullptr; |
|
|
|
session = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
delete packet; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
m_Packets.ReleaseMt (packets); |
|
|
|
if (session) session->FlushData (); |
|
|
|
if (session) session->FlushData (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|