From 4542f4bc876f70ecbc0df543fd2a767c4bec7319 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 4 Jan 2026 11:47:45 -0500 Subject: [PATCH] i2p.streaming.maxResends param --- libi2pd/Destination.cpp | 4 +++- libi2pd/Destination.h | 7 +++++-- libi2pd/Streaming.cpp | 8 +++++--- libi2pd/Streaming.h | 4 ++-- libi2pd_client/ClientContext.cpp | 5 ++++- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/libi2pd/Destination.cpp b/libi2pd/Destination.cpp index 6100224b..37ad3dd1 100644 --- a/libi2pd/Destination.cpp +++ b/libi2pd/Destination.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2025, The PurpleI2P Project +* Copyright (c) 2013-2026, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -981,6 +981,7 @@ namespace client m_StreamingMaxConcurrentStreams (DEFAULT_MAX_CONCURRENT_STREAMS), m_StreamingMaxConnsPerMinute (DEFAULT_MAX_CONNS_PER_MINUTE), m_StreamingMaxWindowSize (i2p::stream::MAX_WINDOW_SIZE), + m_StreamingMaxResends (i2p::stream::MAX_NUM_RESEND_ATTEMPTS), m_IsStreamingAnswerPings (DEFAULT_ANSWER_PINGS), m_IsStreamingDontSign (DEFAULT_DONT_SIGN), m_LastPort (0), m_DatagramDestination (nullptr), m_RefCounter (0), m_LastPublishedTimestamp (0), m_ReadyChecker(service) @@ -1059,6 +1060,7 @@ namespace client m_StreamingMaxWindowSize = i2p::stream::MIN_WINDOW_SIZE; params->Get (I2CP_PARAM_STREAMING_ANSWER_PINGS, m_IsStreamingAnswerPings); params->Get (I2CP_PARAM_STREAMING_DONT_SIGN, m_IsStreamingDontSign); + params->Get (I2CP_PARAM_STREAMING_MAX_RESENDS, m_StreamingMaxResends); if (GetLeaseSetType () == i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2) { diff --git a/libi2pd/Destination.h b/libi2pd/Destination.h index d5ed00a6..c20c80c0 100644 --- a/libi2pd/Destination.h +++ b/libi2pd/Destination.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2025, The PurpleI2P Project +* Copyright (c) 2013-2026, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -104,6 +104,7 @@ namespace client const char I2CP_PARAM_STREAMING_MAX_CONNS_PER_MINUTE[] ="i2p.streaming.maxConnsPerMinute"; // per dest const int DEFAULT_MAX_CONNS_PER_MINUTE = 0; // unlimited const char I2CP_PARAM_STREAMING_MAX_WINDOW_SIZE[] = "i2p.streaming.maxWindowSize"; + const char I2CP_PARAM_STREAMING_MAX_RESENDS[] = "i2p.streaming.maxResends"; const char I2CP_PARAM_STREAMING_DONT_SIGN[] = "i2p.streaming.dontSign"; const int DEFAULT_DONT_SIGN = false; @@ -279,6 +280,7 @@ namespace client bool IsStreamingAnswerPings () const { return m_IsStreamingAnswerPings; } bool IsStreamingDontSign () const { return m_IsStreamingDontSign; } int GetStreamingMaxWindowSize () const { return m_StreamingMaxWindowSize; } + int GetStreamingMaxResends () const { return m_StreamingMaxResends; } // datagram i2p::datagram::DatagramDestination * GetDatagramDestination () const { return m_DatagramDestination; }; @@ -320,7 +322,8 @@ namespace client i2p::data::CryptoKeyType m_PreferredCryptoType; int m_StreamingAckDelay,m_StreamingOutboundSpeed, m_StreamingInboundSpeed, - m_StreamingMaxConcurrentStreams, m_StreamingMaxConnsPerMinute, m_StreamingMaxWindowSize; + m_StreamingMaxConcurrentStreams, m_StreamingMaxConnsPerMinute, m_StreamingMaxWindowSize, + m_StreamingMaxResends; bool m_IsStreamingAnswerPings, m_IsStreamingDontSign; std::shared_ptr m_StreamingDestination; // default std::map > m_StreamingDestinationsByPorts; diff --git a/libi2pd/Streaming.cpp b/libi2pd/Streaming.cpp index 65ed5a2c..2fe5e544 100644 --- a/libi2pd/Streaming.cpp +++ b/libi2pd/Streaming.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2025, The PurpleI2P Project +* Copyright (c) 2013-2026, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -103,6 +103,7 @@ namespace stream m_LastSendTime (0), m_LastACKRecieveTime (0), m_ACKRecieveInterval (local.GetOwner ()->GetStreamingAckDelay ()), m_RemoteLeaseChangeTime (0), m_LastWindowIncTime (0), m_LastACKRequestTime (0), m_LastACKSendTime (0), m_PacketACKInterval (1), m_PacketACKIntervalRem (0), // for limit inbound speed + m_MaxNumResendAttempts (local.GetOwner ()->GetStreamingMaxResends ()), m_NumResendAttempts (0), m_NumPacketsToSend (0), m_JitterAccum (0), m_JitterDiv (1), m_MTU (STREAMING_MTU) { RAND_bytes ((uint8_t *)&m_RecvStreamID, 4); @@ -135,6 +136,7 @@ namespace stream m_LastACKRecieveTime (0), m_ACKRecieveInterval (local.GetOwner ()->GetStreamingAckDelay ()), m_RemoteLeaseChangeTime (0), m_LastWindowIncTime (0), m_LastACKRequestTime (0), m_LastACKSendTime (0), m_PacketACKInterval (1), m_PacketACKIntervalRem (0), // for limit inbound speed + m_MaxNumResendAttempts (local.GetOwner ()->GetStreamingMaxResends ()), m_NumResendAttempts (0), m_NumPacketsToSend (0), m_JitterAccum (0), m_JitterDiv (1), m_MTU (STREAMING_MTU) { RAND_bytes ((uint8_t *)&m_RecvStreamID, 4); @@ -1698,9 +1700,9 @@ namespace stream Close (); return; } - if (m_NumResendAttempts >= MAX_NUM_RESEND_ATTEMPTS) + if (m_NumResendAttempts >= m_MaxNumResendAttempts) { - LogPrint (eLogWarning, "Streaming: packet was not ACKed after ", MAX_NUM_RESEND_ATTEMPTS, " attempts, terminate, rSID=", m_RecvStreamID, ", sSID=", m_SendStreamID); + LogPrint (eLogWarning, "Streaming: packet was not ACKed after ", m_MaxNumResendAttempts, " attempts, terminate, rSID=", m_RecvStreamID, ", sSID=", m_SendStreamID); m_Status = eStreamStatusReset; Close (); return; diff --git a/libi2pd/Streaming.h b/libi2pd/Streaming.h index 4cd46f01..85838d5d 100644 --- a/libi2pd/Streaming.h +++ b/libi2pd/Streaming.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2025, The PurpleI2P Project +* Copyright (c) 2013-2026, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -301,7 +301,7 @@ namespace stream uint64_t m_MinPacingTime, m_PacingTime, m_PacingTimeRem, // microseconds m_LastSendTime, m_LastACKRecieveTime, m_ACKRecieveInterval, m_RemoteLeaseChangeTime, m_LastWindowIncTime, m_LastACKRequestTime; // milliseconds uint64_t m_LastACKSendTime, m_PacketACKInterval, m_PacketACKIntervalRem; // for limit inbound speed - int m_NumResendAttempts, m_NumPacketsToSend; + int m_MaxNumResendAttempts, m_NumResendAttempts, m_NumPacketsToSend; uint64_t m_JitterAccum; int m_JitterDiv; size_t m_MTU; diff --git a/libi2pd_client/ClientContext.cpp b/libi2pd_client/ClientContext.cpp index e55fe217..b1eebe70 100644 --- a/libi2pd_client/ClientContext.cpp +++ b/libi2pd_client/ClientContext.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2025, The PurpleI2P Project +* Copyright (c) 2013-2026, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -483,6 +483,7 @@ namespace client options.Insert (I2CP_PARAM_STREAMING_PROFILE, GetI2CPOption(section, I2CP_PARAM_STREAMING_PROFILE, DEFAULT_STREAMING_PROFILE)); options.Insert (I2CP_PARAM_STREAMING_MAX_WINDOW_SIZE, GetI2CPOption(section, I2CP_PARAM_STREAMING_MAX_WINDOW_SIZE, i2p::stream::MAX_WINDOW_SIZE)); options.Insert (I2CP_PARAM_LEASESET_TYPE, GetI2CPOption(section, I2CP_PARAM_LEASESET_TYPE, DEFAULT_LEASESET_TYPE)); + options.Insert (I2CP_PARAM_STREAMING_MAX_RESENDS, GetI2CPOption(section, I2CP_PARAM_STREAMING_MAX_RESENDS, i2p::stream::MAX_NUM_RESEND_ATTEMPTS)); #if OPENSSL_PQ std::string encType = GetI2CPStringOption(section, I2CP_PARAM_LEASESET_ENCRYPTION_TYPE, isServer ? "6,4" : "6,4,0"); #else @@ -535,6 +536,8 @@ namespace client options.Insert (I2CP_PARAM_STREAMING_PROFILE, value); if (i2p::config::GetOption(prefix + I2CP_PARAM_STREAMING_MAX_WINDOW_SIZE, value)) options.Insert (I2CP_PARAM_STREAMING_MAX_WINDOW_SIZE, value); + if (i2p::config::GetOption(prefix + I2CP_PARAM_STREAMING_MAX_RESENDS, value)) + options.Insert (I2CP_PARAM_STREAMING_MAX_RESENDS, value); } void ClientContext::ReadTunnels ()