don't consider empty tunnel message as error

This commit is contained in:
orignal
2026-06-12 07:52:49 -04:00
parent 4a292d3b79
commit 7fc2136166
+12 -14
View File
@@ -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<I2NPMessage> 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<i2p::I2NPMessage> 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<TunnelTransportSender>();
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;
}
}
}
}