local delivery type for multi cloves garlic message

This commit is contained in:
orignal
2025-12-10 18:02:22 -05:00
parent 1ce9671878
commit 8ff60128fe
2 changed files with 6 additions and 5 deletions

View File

@@ -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<const I2NPMessage> msg, uint8_t * buf, size_t len)
size_t ECIESX25519AEADRatchetSession::CreateGarlicClove (std::shared_ptr<const I2NPMessage> 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;

View File

@@ -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<const I2NPMessage> msg, bool first, uint8_t * payload);
size_t CreateGarlicClove (std::shared_ptr<const I2NPMessage> msg, uint8_t * buf, size_t len);
size_t CreateGarlicClove (std::shared_ptr<const I2NPMessage> msg, uint8_t * buf, size_t len, bool alwaysLocal = false);
size_t CreateLeaseSetClove (std::shared_ptr<const i2p::data::LocalLeaseSet> ls, uint64_t ts, uint8_t * buf, size_t len);
size_t CreatePaddingClove (uint8_t paddingSize, uint8_t * buf, size_t len);