From 7fc21361663a0287123b92c9afbe229a87749e06 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 12 Jun 2026 07:52:49 -0400 Subject: [PATCH] don't consider empty tunnel message as error --- libi2pd/TunnelEndpoint.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/libi2pd/TunnelEndpoint.cpp b/libi2pd/TunnelEndpoint.cpp index 66b7effa..22b62984 100644 --- a/libi2pd/TunnelEndpoint.cpp +++ b/libi2pd/TunnelEndpoint.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 * @@ -21,7 +21,7 @@ namespace i2p { namespace tunnel { - + void TunnelEndpoint::HandleDecryptedTunnelDataMsg (std::shared_ptr msg) { m_NumReceivedBytes += TUNNEL_DATA_MSG_SIZE; @@ -152,8 +152,6 @@ namespace tunnel fragment += size; } } - else - LogPrint (eLogError, "TunnelMessage: Zero not found"); } void TunnelEndpoint::HandleFollowOnFragment (uint32_t msgID, bool isLastFragment, @@ -258,7 +256,7 @@ namespace tunnel void TunnelEndpoint::AddOutOfSequenceFragment (uint32_t msgID, uint8_t fragmentNum, bool isLastFragment, const uint8_t * fragment, size_t size) { - if (!m_OutOfSequenceFragments.try_emplace ((uint64_t)msgID << 32 | fragmentNum, + if (!m_OutOfSequenceFragments.try_emplace ((uint64_t)msgID << 32 | fragmentNum, isLastFragment, i2p::util::GetMillisecondsSinceEpoch (), fragment, size).second) LogPrint (eLogInfo, "TunnelMessage: Duplicate out-of-sequence fragment ", fragmentNum, " of message ", msgID); } @@ -297,7 +295,7 @@ namespace tunnel *newMsg = *(msg.data); msg.data = newMsg; } - if (msg.data->Concat (it->second.data.data (), size) < size) // concatenate out-of-sync fragment + if (msg.data->Concat (it->second.data.data (), size) < size) // concatenate out-of-sync fragment LogPrint (eLogError, "TunnelMessage: Tunnel endpoint I2NP buffer overflow ", msg.data->maxLen); if (it->second.isLastFragment) // message complete @@ -319,7 +317,7 @@ namespace tunnel } uint8_t typeID = msg.data->GetTypeID (); LogPrint (eLogDebug, "TunnelMessage: Handle fragment of ", msg.data->GetLength (), " bytes, msg type ", (int)typeID); - + switch (msg.deliveryType) { case eDeliveryTypeLocal: @@ -364,9 +362,9 @@ namespace tunnel } void TunnelEndpoint::SendMessageTo (const i2p::data::IdentHash& to, std::shared_ptr msg) - { + { if (msg) - { + { if (!m_Sender && m_I2NPMsgs.empty ()) // first message m_CurrentHash = to; else if (m_CurrentHash != to) // new target router @@ -376,21 +374,21 @@ namespace tunnel m_CurrentHash = to; // set new target router } // otherwise add msg to the list for current target router m_I2NPMsgs.push_back (msg); - } + } } - + void TunnelEndpoint::FlushI2NPMsgs () { if (!m_I2NPMsgs.empty ()) { if (!m_Sender) m_Sender = std::make_unique(); m_Sender->SendMessagesTo (m_CurrentHash, m_I2NPMsgs); // send and clear - } - } + } + } const i2p::data::IdentHash * TunnelEndpoint::GetCurrentHash () const { return (m_Sender || !m_I2NPMsgs.empty ()) ? &m_CurrentHash : nullptr; - } + } } }