From 4e11c3f11b6d67b47064cd4c762b418a8571b0d8 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 18 Feb 2026 19:27:35 -0500 Subject: [PATCH] moved last repliable datagram time to UDPConnection --- libi2pd_client/UDPTunnel.cpp | 13 ++++++------- libi2pd_client/UDPTunnel.h | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libi2pd_client/UDPTunnel.cpp b/libi2pd_client/UDPTunnel.cpp index 4d38d0a7..cf2705fe 100644 --- a/libi2pd_client/UDPTunnel.cpp +++ b/libi2pd_client/UDPTunnel.cpp @@ -55,7 +55,7 @@ namespace client 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 - m_LastSession->LastRepliableDatagramTime = i2p::util::GetMillisecondsSinceEpoch (); + m_LastSession->m_LastRepliableDatagramTime = i2p::util::GetMillisecondsSinceEpoch (); } } if (options->Get (UDP_SESSION_ACKED, seqn)) @@ -248,7 +248,7 @@ namespace client UDPConnection (localDestination->GetService(), localDestination->GetDatagramDestination()), IPSocket(localDestination->GetService(), localEndpoint), SendEndpoint(endpoint), LastActivity(i2p::util::GetMillisecondsSinceEpoch()), - LastRepliableDatagramTime (0), LocalPort(ourPort), RemotePort(theirPort) + LocalPort(ourPort), RemotePort(theirPort) { SetIdentity (to); Start (); @@ -279,7 +279,7 @@ namespace client auto session = GetDatagramSession (); uint64_t repliableDatagramInterval = I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL; if (m_RTT && m_RTT >= I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL && m_RTT < I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL*10) repliableDatagramInterval = m_RTT/10; // 10 - 100 ms - if (ts > LastRepliableDatagramTime + repliableDatagramInterval) + if (ts > m_LastRepliableDatagramTime + repliableDatagramInterval) { if (session->GetVersion () == i2p::datagram::eDatagramV3) { @@ -304,7 +304,7 @@ namespace client } else m_Destination->SendDatagram(session, m_Buffer, len, LocalPort, RemotePort); - LastRepliableDatagramTime = ts; + m_LastRepliableDatagramTime = ts; } else m_Destination->SendRawDatagram(session, m_Buffer, len, LocalPort, RemotePort); @@ -397,8 +397,7 @@ namespace client UDPConnection (localDestination->GetService (), localDestination->GetDatagramDestination ()), m_Name (name), m_RemoteDest (remoteDest), m_LocalDest (localDestination), m_LocalEndpoint (localEndpoint), m_ResolveThread (nullptr), m_LocalSocket (nullptr), RemotePort (remotePort), - m_LastPort (0), m_cancel_resolve (false), m_Gzip (gzip), m_DatagramVersion (datagramVersion), - m_LastRepliableDatagramTime (0) + m_LastPort (0), m_cancel_resolve (false), m_Gzip (gzip), m_DatagramVersion (datagramVersion) { } @@ -616,7 +615,7 @@ namespace client { i2p::util::Mapping replyOptions; replyOptions.Put (UDP_SESSION_ACKED, m_LastReceivedPacketNum); - m_LocalDest->GetDatagramDestination ()->SendDatagram (GetDatagramSession (), + m_Destination->SendDatagram (GetDatagramSession (), nullptr, 0, m_LastPort, RemotePort, &replyOptions); // Ack only, no payload m_LastRepliableDatagramTime = i2p::util::GetMillisecondsSinceEpoch (); } diff --git a/libi2pd_client/UDPTunnel.h b/libi2pd_client/UDPTunnel.h index 84673cc9..36524fe5 100644 --- a/libi2pd_client/UDPTunnel.h +++ b/libi2pd_client/UDPTunnel.h @@ -40,6 +40,7 @@ namespace client { i2p::datagram::DatagramDestination * m_Destination; std::weak_ptr m_LastDatagramSession; + uint64_t m_LastRepliableDatagramTime; // millseconds i2p::data::IdentHash Identity; bool isIdentity = false; uint32_t m_NextSendPacketNum = 1, m_LastReceivedPacketNum = 0; @@ -52,7 +53,7 @@ namespace client bool m_IsFirstPacket = true; UDPConnection (boost::asio::io_context& service, i2p::datagram::DatagramDestination * destination): - m_Destination (destination), m_AckTimer (service) {}; + m_Destination (destination), m_LastRepliableDatagramTime (0), m_AckTimer (service) {}; void SetIdentity (const i2p::data::IdentHash& ident) { Identity = ident; isIdentity = true; }; virtual ~UDPConnection () { Stop (); }; @@ -71,7 +72,7 @@ namespace client boost::asio::ip::udp::socket IPSocket; boost::asio::ip::udp::endpoint FromEndpoint; boost::asio::ip::udp::endpoint SendEndpoint; - uint64_t LastActivity, LastRepliableDatagramTime; // milliseconds + uint64_t LastActivity; // milliseconds uint16_t LocalPort; uint16_t RemotePort; @@ -210,7 +211,6 @@ namespace client bool m_Gzip; i2p::datagram::DatagramVersion m_DatagramVersion; std::shared_ptr m_LastSession; - uint64_t m_LastRepliableDatagramTime; // millseconds public: