From 207b13dcabbd0e49b26ceddc94d30a51ecb13f52 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 5 Apr 2022 18:23:52 -0400 Subject: [PATCH] send correct acnt if gaps --- libi2pd/SSU2.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libi2pd/SSU2.cpp b/libi2pd/SSU2.cpp index a725df03..a27cf063 100644 --- a/libi2pd/SSU2.cpp +++ b/libi2pd/SSU2.cpp @@ -992,7 +992,19 @@ namespace transport htobe32buf (buf + 3, ackThrough); // Ack Through uint8_t acnt = 0; if (ackThrough) - acnt = std::min ((int)ackThrough, 255); + { + if (m_OutOfSequencePackets.empty ()) + acnt = std::min ((int)ackThrough, 255); // no gaps + else + { + auto it = m_OutOfSequencePackets.rbegin (); it++; // prev packet num + while (it != m_OutOfSequencePackets.rend () && *it == ackThrough - acnt - 1) + { + acnt++; + it++; + } + } + } buf[7] = acnt; // acnt // TODO: ranges return 8; @@ -1106,6 +1118,11 @@ namespace transport else ++it; } + if (m_OutOfSequencePackets.size () > 255) + { + m_ReceivePacketNum = *m_OutOfSequencePackets.rbegin (); + m_OutOfSequencePackets.clear (); + } } SSU2Server::SSU2Server ():