From 1d7c7ac14898b0f8e956685a49b1382b0132d221 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 29 Aug 2025 11:16:54 -0400 Subject: [PATCH] fixed #2231. Close outgoing stream if LeaseSet not found --- libi2pd/Streaming.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libi2pd/Streaming.cpp b/libi2pd/Streaming.cpp index 122a26d2..25fb7b5d 100644 --- a/libi2pd/Streaming.cpp +++ b/libi2pd/Streaming.cpp @@ -1817,19 +1817,29 @@ namespace stream auto remoteLeaseSet = m_LocalDestination.GetOwner ()->FindLeaseSet (m_RemoteIdentity->GetIdentHash ()); if (!remoteLeaseSet) { - LogPrint (eLogWarning, "Streaming: LeaseSet ", m_RemoteIdentity->GetIdentHash ().ToBase64 (), m_RemoteLeaseSet ? " expired" : " not found"); + LogPrint (eLogWarning, "Streaming: LeaseSet ", m_RemoteIdentity->GetIdentHash ().ToBase32 (), m_RemoteLeaseSet ? " expired" : " not found"); if (!m_IsIncoming) // outgoing { + auto requestCallback = [s = shared_from_this ()](std::shared_ptr ls) + { + if (!ls && s->m_Status == eStreamStatusOpen) // LeaseSet not found + { + // close the socket without sending FIN or RST + s->m_Status = eStreamStatusClosed; + s->AsyncClose (); + } + }; + if (m_RemoteLeaseSet && m_RemoteLeaseSet->IsPublishedEncrypted ()) { m_LocalDestination.GetOwner ()->RequestDestinationWithEncryptedLeaseSet ( - std::make_shared(m_RemoteIdentity)); + std::make_shared(m_RemoteIdentity), requestCallback); return; // we keep m_RemoteLeaseSet for possible next request } else { m_RemoteLeaseSet = nullptr; - m_LocalDestination.GetOwner ()->RequestDestination (m_RemoteIdentity->GetIdentHash ()); // try to request for a next attempt + m_LocalDestination.GetOwner ()->RequestDestination (m_RemoteIdentity->GetIdentHash (), requestCallback); // try to request for a next attempt } } else // incoming