mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-10-22 19:49:03 +01:00
send ack to repliable datagram only if requested
Some checks are pending
Build Debian packages / trixie (push) Waiting to run
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
Some checks are pending
Build Debian packages / trixie (push) Waiting to run
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
This commit is contained in:
parent
a6d8203f1c
commit
bdc8263196
1 changed files with 23 additions and 12 deletions
|
@ -22,6 +22,7 @@ namespace client
|
|||
constexpr std::string_view UDP_SESSION_FLAGS { "flags" };
|
||||
|
||||
constexpr uint8_t UDP_SESSION_FLAG_RESET_PATH = 0x01;
|
||||
constexpr uint8_t UDP_SESSION_FLAG_ACK_REQUESTED = 0x02;
|
||||
|
||||
void I2PUDPServerTunnel::HandleRecvFromI2P(const i2p::data::IdentityEx& from, uint16_t fromPort, uint16_t toPort,
|
||||
const uint8_t * buf, size_t len, const i2p::util::Mapping * options)
|
||||
|
@ -37,18 +38,22 @@ namespace client
|
|||
LogPrint (eLogInfo, "UDP Server: Send exception: ", ec.message (), " to ", m_RemoteEndpoint);
|
||||
if (options)
|
||||
{
|
||||
uint8_t flags = 0;
|
||||
if (options->Get (UDP_SESSION_FLAGS, flags) && (flags & UDP_SESSION_FLAG_RESET_PATH))
|
||||
m_LastSession->GetDatagramSession ()->DropSharedRoutingPath ();
|
||||
uint32_t seqn = 0;
|
||||
if (options->Get (UDP_SESSION_SEQN, seqn) && seqn > m_LastSession->m_LastReceivedPacketNum)
|
||||
{
|
||||
m_LastSession->m_LastReceivedPacketNum = seqn;
|
||||
i2p::util::Mapping replyOptions;
|
||||
replyOptions.Put (UDP_SESSION_ACKED, m_LastSession->m_LastReceivedPacketNum);
|
||||
m_LastSession->m_Destination->SendDatagram(m_LastSession->GetDatagramSession (),
|
||||
nullptr, 0, m_LastSession->LocalPort, m_LastSession->RemotePort, &replyOptions); // Ack only, no payload
|
||||
}
|
||||
uint8_t flags = 0;
|
||||
if (options->Get (UDP_SESSION_FLAGS, flags))
|
||||
{
|
||||
if (flags & UDP_SESSION_FLAG_RESET_PATH)
|
||||
m_LastSession->GetDatagramSession ()->DropSharedRoutingPath ();
|
||||
if (flags & UDP_SESSION_FLAG_ACK_REQUESTED)
|
||||
{
|
||||
i2p::util::Mapping replyOptions;
|
||||
replyOptions.Put (UDP_SESSION_ACKED, m_LastSession->m_LastReceivedPacketNum);
|
||||
m_LastSession->m_Destination->SendDatagram(m_LastSession->GetDatagramSession (),
|
||||
nullptr, 0, m_LastSession->LocalPort, m_LastSession->RemotePort, &replyOptions); // Ack only, no payload
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,7 +404,11 @@ namespace client
|
|||
m_RTT = 0;
|
||||
flags |= UDP_SESSION_FLAG_RESET_PATH;
|
||||
}
|
||||
m_UnackedDatagrams.push_back ({ m_NextSendPacketNum, ts });
|
||||
if (!m_RTT || !m_AckTimerSeqn)
|
||||
{
|
||||
flags |= UDP_SESSION_FLAG_ACK_REQUESTED;
|
||||
m_UnackedDatagrams.push_back ({ m_NextSendPacketNum, ts });
|
||||
}
|
||||
i2p::util::Mapping options;
|
||||
options.Put (UDP_SESSION_SEQN, m_NextSendPacketNum);
|
||||
if (m_LastReceivedPacketNum > 0)
|
||||
|
@ -487,8 +496,10 @@ namespace client
|
|||
{
|
||||
uint32_t seqn = 0;
|
||||
if (options->Get (UDP_SESSION_SEQN, seqn) && seqn > m_LastReceivedPacketNum)
|
||||
{
|
||||
m_LastReceivedPacketNum = seqn;
|
||||
uint8_t flags = 0;
|
||||
if (options->Get (UDP_SESSION_FLAGS, flags) && (flags & UDP_SESSION_FLAG_ACK_REQUESTED))
|
||||
{
|
||||
i2p::util::Mapping replyOptions;
|
||||
replyOptions.Put (UDP_SESSION_ACKED, m_LastReceivedPacketNum);
|
||||
m_LocalDest->GetDatagramDestination ()->SendDatagram (GetDatagramSession (),
|
||||
|
@ -561,7 +572,7 @@ namespace client
|
|||
m_RTT = 0;
|
||||
// send empty packet with reset path flag
|
||||
i2p::util::Mapping options;
|
||||
options.Put (UDP_SESSION_FLAGS, UDP_SESSION_FLAG_RESET_PATH);
|
||||
options.Put (UDP_SESSION_FLAGS, UDP_SESSION_FLAG_RESET_PATH | UDP_SESSION_FLAG_ACK_REQUESTED);
|
||||
auto session = GetDatagramSession ();
|
||||
session->DropSharedRoutingPath ();
|
||||
m_LocalDest->GetDatagramDestination ()->SendDatagram (session, nullptr, 0, 0, 0, &options);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue