diff --git a/libi2pd/LeaseSet.cpp b/libi2pd/LeaseSet.cpp index 3debd06c..f2b4f561 100644 --- a/libi2pd/LeaseSet.cpp +++ b/libi2pd/LeaseSet.cpp @@ -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 * @@ -321,7 +321,7 @@ namespace data if (readIdentity || !GetIdentity ()) { identity = netdb.NewIdentity (buf, len); - if (!identity) return; + if (!identity || !identity->GetFullLen ()) return; SetIdentity (identity); } else @@ -401,8 +401,12 @@ namespace data { size_t offset = 0; // properties - uint16_t propertiesLen = bufbe16toh (buf + offset); offset += 2; - offset += propertiesLen; // skip for now. TODO: implement properties + if (offset + 2 > len) return 0; + m_Properties.CleanUp (); + uint16_t propertiesLen = bufbe16toh (buf + offset); + if (propertiesLen) + m_Properties.FromBuffer (buf + offset, len - offset); + offset += propertiesLen + 2; // key sections CryptoKeyType preferredKeyType = m_EncryptionType; m_EncryptionType = 0; diff --git a/libi2pd/LeaseSet.h b/libi2pd/LeaseSet.h index 46f40cb5..f95fa639 100644 --- a/libi2pd/LeaseSet.h +++ b/libi2pd/LeaseSet.h @@ -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 * @@ -20,6 +20,7 @@ #include "I2PEndian.h" #include "Blinding.h" #include "CryptoKey.h" +#include "util.h" namespace i2p { @@ -63,12 +64,12 @@ namespace data const size_t MAX_LS_BUFFER_SIZE = 8192; #else const size_t MAX_LS_BUFFER_SIZE = 4096; -#endif +#endif const size_t LEASE_SIZE = 44; // 32 + 4 + 8 const size_t LEASE2_SIZE = 40; // 32 + 4 + 4 const uint8_t MAX_NUM_LEASES = 16; const uint64_t LEASESET_EXPIRATION_TIME_THRESHOLD = 12*60*1000; // in milliseconds - + const uint8_t NETDB_STORE_TYPE_LEASESET = 1; class LeaseSet: public RoutingDestination { @@ -155,9 +156,9 @@ namespace data public: LeaseSet2 (uint8_t storeType): LeaseSet (true), m_StoreType (storeType) {}; // for update - LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases = true, + LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases = true, std::shared_ptr dest = nullptr, CryptoKeyType preferredCrypto = CRYPTO_KEY_TYPE_ECIES_X25519_AEAD); - LeaseSet2 (const uint8_t * buf, size_t len, std::shared_ptr key, + LeaseSet2 (const uint8_t * buf, size_t len, std::shared_ptr key, std::shared_ptr dest = nullptr, const uint8_t * secret = nullptr, CryptoKeyType preferredCrypto = CRYPTO_KEY_TYPE_ECIES_X25519_AEAD); // store type 5, called from local netdb only uint8_t GetStoreType () const override { return m_StoreType; }; uint32_t GetPublishedTimestamp () const override { return m_PublishedTimestamp; }; @@ -175,7 +176,7 @@ namespace data void ReadFromBuffer (const uint8_t * buf, size_t len, std::shared_ptr dest, bool readIdentity = true, bool verifySignature = true); - void ReadFromBufferEncrypted (const uint8_t * buf, size_t len, std::shared_ptr key, + void ReadFromBufferEncrypted (const uint8_t * buf, size_t len, std::shared_ptr key, std::shared_ptr dest, const uint8_t * secret); size_t ReadStandardLS2TypeSpecificPart (const uint8_t * buf, size_t len, std::shared_ptr dest); size_t ReadMetaLS2TypeSpecificPart (const uint8_t * buf, size_t len); @@ -195,6 +196,7 @@ namespace data std::shared_ptr m_TransientVerifier; CryptoKeyType m_EncryptionType; std::shared_ptr m_Encryptor; // for standardLS2 + i2p::util::Mapping m_Properties; }; // also called from Streaming.cpp