From 72b8ef3eb4f49842d25b69b97243a9e1f86c30b6 Mon Sep 17 00:00:00 2001 From: acetone <63557806+freeacetone@users.noreply.github.com> Date: Sat, 8 Aug 2026 17:41:36 +0300 Subject: [PATCH] configurable udp tunnel window --- libi2pd_client/ClientContext.cpp | 10 ++++++++++ libi2pd_client/ClientContext.h | 1 + 2 files changed, 11 insertions(+) diff --git a/libi2pd_client/ClientContext.cpp b/libi2pd_client/ClientContext.cpp index a8cece86..8748f694 100644 --- a/libi2pd_client/ClientContext.cpp +++ b/libi2pd_client/ClientContext.cpp @@ -564,6 +564,14 @@ namespace client options.Insert (I2CP_PARAM_STREAMING_MAX_RESENDS, value); } + static size_t GetUDPTunnelMaxWindow (const boost::property_tree::ptree& section) + { + size_t w = section.get (UDP_TUNNEL_MAX_WINDOW, I2P_UDP_DEFAULT_MAX_NUM_UNACKED_DATAGRAMS); + if (w < I2P_UDP_MIN_MAX_NUM_UNACKED_DATAGRAMS) w = I2P_UDP_MIN_MAX_NUM_UNACKED_DATAGRAMS; + if (w > I2P_UDP_MAX_NUM_UNACKED_DATAGRAMS) w = I2P_UDP_MAX_NUM_UNACKED_DATAGRAMS; + return w; + } + void ClientContext::ReadTunnels () { int numClientTunnels = 0, numServerTunnels = 0; @@ -686,6 +694,7 @@ namespace client int datagramVersion = (i2p::datagram::DatagramVersion)section.second.get (UDP_CLIENT_TUNNEL_DATAGRAM_VERSION, (int)i2p::datagram::eDatagramV3); auto clientTunnel = std::make_shared (name, dest, end, localDestination, destinationPort, gzip, (i2p::datagram::DatagramVersion)datagramVersion); + clientTunnel->SetMaxWindow (GetUDPTunnelMaxWindow (section.second)); uint32_t keepAlive = section.second.get(I2P_CLIENT_TUNNEL_KEEP_ALIVE_INTERVAL, 0); if (keepAlive) @@ -864,6 +873,7 @@ namespace client } auto localAddress = boost::asio::ip::make_address(address); auto serverTunnel = std::make_shared(name, localDestination, localAddress, endpoint, inPort, gzip); + serverTunnel->SetMaxWindow (GetUDPTunnelMaxWindow (section.second)); if(!isUniqueLocal) { LogPrint(eLogInfo, "Clients: Disabling loopback address mapping"); diff --git a/libi2pd_client/ClientContext.h b/libi2pd_client/ClientContext.h index 0970dd42..ad1a6af7 100644 --- a/libi2pd_client/ClientContext.h +++ b/libi2pd_client/ClientContext.h @@ -69,6 +69,7 @@ namespace client const char I2P_SERVER_TUNNEL_ENABLE_UNIQUE_LOCAL[] = "enableuniquelocal"; const char I2P_SERVER_TUNNEL_SSL[] = "ssl"; const char UDP_CLIENT_TUNNEL_DATAGRAM_VERSION[] = "datagramversion"; + const char UDP_TUNNEL_MAX_WINDOW[] = "maxwindow"; const char TORRENTS_TUNNEL_KEYS[] = "keys"; const char TORRENTS_TUNNEL_SIGNATURE_TYPE[] = "signaturetype"; const char TORRENTS_TUNNEL_TORRENTS_DIR[] = "torrentsdir";