From e0ac8a7298105345edba1ea541f8ebc0b86758fd Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 24 Jul 2024 19:09:46 -0400 Subject: [PATCH] check if destination is ready. Create garlic message before selectiing routing path --- libi2pd_client/I2CP.cpp | 13 +++++++++---- libi2pd_client/I2CP.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libi2pd_client/I2CP.cpp b/libi2pd_client/I2CP.cpp index f09b423d..8f677203 100644 --- a/libi2pd_client/I2CP.cpp +++ b/libi2pd_client/I2CP.cpp @@ -202,6 +202,7 @@ namespace client LogPrint (eLogError, "I2CP: Failed to create remote session"); return false; } + auto garlic = remoteSession->WrapSingleMessage (msg); // shared routing path mitgh be dropped here auto path = remoteSession->GetSharedRoutingPath (); std::shared_ptr outboundTunnel; std::shared_ptr remoteLease; @@ -236,7 +237,6 @@ namespace client if (remoteLease && outboundTunnel) { std::vector msgs; - auto garlic = remoteSession->WrapSingleMessage (msg); msgs.push_back (i2p::tunnel::TunnelMessageBlock { i2p::tunnel::eDeliveryTypeTunnel, @@ -787,9 +787,14 @@ namespace client { offset += 4; uint32_t nonce = bufbe32toh (buf + offset + payloadLen); - if (m_IsSendAccepted) - SendMessageStatusMessage (nonce, eI2CPMessageStatusAccepted); // accepted - m_Destination->SendMsgTo (buf + offset, payloadLen, identity.GetIdentHash (), nonce); + if (m_Destination->IsReady ()) + { + if (m_IsSendAccepted) + SendMessageStatusMessage (nonce, eI2CPMessageStatusAccepted); // accepted + m_Destination->SendMsgTo (buf + offset, payloadLen, identity.GetIdentHash (), nonce); + } + else + SendMessageStatusMessage (nonce, eI2CPMessageStatusNoLocalTunnels); } else LogPrint(eLogError, "I2CP: Cannot send message, too big"); diff --git a/libi2pd_client/I2CP.h b/libi2pd_client/I2CP.h index 6ef78861..02ec72d9 100644 --- a/libi2pd_client/I2CP.h +++ b/libi2pd_client/I2CP.h @@ -58,6 +58,7 @@ namespace client eI2CPMessageStatusAccepted = 1, eI2CPMessageStatusGuaranteedSuccess = 4, eI2CPMessageStatusGuaranteedFailure = 5, + eI2CPMessageStatusNoLocalTunnels = 16, eI2CPMessageStatusNoLeaseSet = 21 };