|
|
|
@ -32,7 +32,7 @@ namespace transport
@@ -32,7 +32,7 @@ namespace transport
|
|
|
|
|
TransportSession (in_RemoteRouter, SSU2_CONNECT_TIMEOUT), |
|
|
|
|
m_Server (server), m_Address (addr), m_DestConnID (0), m_SourceConnID (0), |
|
|
|
|
m_State (eSSU2SessionStateUnknown), m_SendPacketNum (0), m_ReceivePacketNum (0), |
|
|
|
|
m_IsDataReceived (false) |
|
|
|
|
m_IsDataReceived (false), m_WindowSize (SSU2_MAX_WINDOW_SIZE) |
|
|
|
|
{ |
|
|
|
|
m_NoiseState.reset (new i2p::crypto::NoiseSymmetricState); |
|
|
|
|
if (in_RemoteRouter && m_Address) |
|
|
|
@ -110,12 +110,12 @@ namespace transport
@@ -110,12 +110,12 @@ namespace transport
|
|
|
|
|
|
|
|
|
|
void SSU2Session::SendQueue () |
|
|
|
|
{ |
|
|
|
|
if (!m_SendQueue.empty ()) |
|
|
|
|
if (!m_SendQueue.empty () && m_SentPackets.size () <= m_WindowSize) |
|
|
|
|
{ |
|
|
|
|
auto nextResend = i2p::util::GetSecondsSinceEpoch () + SSU2_RESEND_INTERVAL; |
|
|
|
|
auto packet = std::make_shared<SentPacket>(); |
|
|
|
|
packet->payloadSize += CreateAckBlock (packet->payload + packet->payloadSize, SSU2_MAX_PAYLOAD_SIZE - packet->payloadSize); |
|
|
|
|
while (!m_SendQueue.empty ()) |
|
|
|
|
while (!m_SendQueue.empty () && m_SentPackets.size () <= m_WindowSize) |
|
|
|
|
{ |
|
|
|
|
auto msg = m_SendQueue.front (); |
|
|
|
|
size_t len = msg->GetNTCP2Length (); |
|
|
|
@ -180,7 +180,7 @@ namespace transport
@@ -180,7 +180,7 @@ namespace transport
|
|
|
|
|
|
|
|
|
|
void SSU2Session::Resend (uint64_t ts) |
|
|
|
|
{ |
|
|
|
|
if (m_SendQueue.empty ()) return; |
|
|
|
|
if (m_SentPackets.empty ()) return; |
|
|
|
|
std::map<uint32_t, std::shared_ptr<SentPacket> > resentPackets; |
|
|
|
|
for (auto it = m_SentPackets.begin (); it != m_SentPackets.end (); ) |
|
|
|
|
if (ts > it->second->nextResendTime) |
|
|
|
@ -207,6 +207,7 @@ namespace transport
@@ -207,6 +207,7 @@ namespace transport
|
|
|
|
|
m_SentPackets.insert (resentPackets.begin (), resentPackets.end ()); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
SendQueue (); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SSU2Session::ProcessFirstIncomingMessage (uint64_t connID, uint8_t * buf, size_t len) |
|
|
|
@ -746,7 +747,10 @@ namespace transport
@@ -746,7 +747,10 @@ namespace transport
|
|
|
|
|
m_LastActivityTimestamp = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
|
m_NumReceivedBytes += len; |
|
|
|
|
if (UpdateReceivePacketNum (packetNum)) |
|
|
|
|
{ |
|
|
|
|
HandlePayload (payload, payloadSize); |
|
|
|
|
SendQueue (); // if we have something to send
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void SSU2Session::HandlePayload (const uint8_t * buf, size_t len) |
|
|
|
|