From 8ff60128fe4719ca28a2a8433937ac74853dfd3e Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 10 Dec 2025 18:02:22 -0500 Subject: [PATCH] local delivery type for multi cloves garlic message --- libi2pd/ECIESX25519AEADRatchetSession.cpp | 9 +++++---- libi2pd/ECIESX25519AEADRatchetSession.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libi2pd/ECIESX25519AEADRatchetSession.cpp b/libi2pd/ECIESX25519AEADRatchetSession.cpp index 2374489e..7cdff7a5 100644 --- a/libi2pd/ECIESX25519AEADRatchetSession.cpp +++ b/libi2pd/ECIESX25519AEADRatchetSession.cpp @@ -992,7 +992,7 @@ namespace garlic { if (*it != nullptr) { - if ((*it)->GetPayloadLength () + 45 + len > ECIESX25519_OPTIMAL_PAYLOAD_SIZE) + if ((*it)->GetPayloadLength () + 13 + len > ECIESX25519_OPTIMAL_PAYLOAD_SIZE) { auto paddingSize = GetNextPaddingSize (len); if (paddingSize) @@ -1000,7 +1000,7 @@ namespace garlic ret.push_back (WrapPayload (payload, len)); len = 0; } - len += CreateGarlicClove (*it, payload + len, I2NP_MAX_MESSAGE_SIZE - len); + len += CreateGarlicClove (*it, payload + len, I2NP_MAX_MESSAGE_SIZE - len, true); } it++; } @@ -1251,7 +1251,8 @@ namespace garlic return paddingSize; } - size_t ECIESX25519AEADRatchetSession::CreateGarlicClove (std::shared_ptr msg, uint8_t * buf, size_t len) + size_t ECIESX25519AEADRatchetSession::CreateGarlicClove (std::shared_ptr msg, + uint8_t * buf, size_t len, bool alwaysLocal) { if (!msg) return 0; uint16_t cloveSize = msg->GetPayloadLength () + 9 + 1; @@ -1260,7 +1261,7 @@ namespace garlic buf[0] = eECIESx25519BlkGalicClove; // clove type htobe16buf (buf + 1, cloveSize); // size buf += 3; - if (m_Destination) + if (!alwaysLocal && m_Destination) { *buf = (eGarlicDeliveryTypeDestination << 5); memcpy (buf + 1, *m_Destination, 32); buf += 32; diff --git a/libi2pd/ECIESX25519AEADRatchetSession.h b/libi2pd/ECIESX25519AEADRatchetSession.h index fb2fc8f1..51063f84 100644 --- a/libi2pd/ECIESX25519AEADRatchetSession.h +++ b/libi2pd/ECIESX25519AEADRatchetSession.h @@ -219,7 +219,7 @@ namespace garlic bool NewExistingSessionMessage (const uint8_t * payload, size_t len, uint8_t * out, size_t outLen); size_t CreatePayload (std::shared_ptr msg, bool first, uint8_t * payload); - size_t CreateGarlicClove (std::shared_ptr msg, uint8_t * buf, size_t len); + size_t CreateGarlicClove (std::shared_ptr msg, uint8_t * buf, size_t len, bool alwaysLocal = false); size_t CreateLeaseSetClove (std::shared_ptr ls, uint64_t ts, uint8_t * buf, size_t len); size_t CreatePaddingClove (uint8_t paddingSize, uint8_t * buf, size_t len);