From d7e7f06e88bc5c297054845ac2c04f009026a1b3 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 17 Apr 2019 15:53:07 -0400 Subject: [PATCH] re-request encrypted LeaseSet --- libi2pd/LeaseSet.cpp | 4 ++-- libi2pd/LeaseSet.h | 4 +++- libi2pd/Streaming.cpp | 7 ++++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/libi2pd/LeaseSet.cpp b/libi2pd/LeaseSet.cpp index 38d24cdc..8b9edb79 100644 --- a/libi2pd/LeaseSet.cpp +++ b/libi2pd/LeaseSet.cpp @@ -394,7 +394,7 @@ namespace data } LeaseSet2::LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases): - LeaseSet (storeLeases), m_StoreType (storeType) + LeaseSet (storeLeases), m_StoreType (storeType), m_OrigStoreType (storeType) { SetBuffer (buf, len); if (storeType == NETDB_STORE_TYPE_ENCRYPTED_LEASESET2) @@ -404,7 +404,7 @@ namespace data } LeaseSet2::LeaseSet2 (const uint8_t * buf, size_t len, std::shared_ptr key): - LeaseSet (true), m_StoreType (NETDB_STORE_TYPE_ENCRYPTED_LEASESET2) + LeaseSet (true), m_StoreType (NETDB_STORE_TYPE_ENCRYPTED_LEASESET2), m_OrigStoreType (NETDB_STORE_TYPE_ENCRYPTED_LEASESET2) { ReadFromBufferEncrypted (buf, len, key); } diff --git a/libi2pd/LeaseSet.h b/libi2pd/LeaseSet.h index b68679d5..94a19b1b 100644 --- a/libi2pd/LeaseSet.h +++ b/libi2pd/LeaseSet.h @@ -78,6 +78,7 @@ namespace data bool operator== (const LeaseSet& other) const { return m_BufferLen == other.m_BufferLen && !memcmp (m_Buffer, other.m_Buffer, m_BufferLen); }; virtual uint8_t GetStoreType () const { return NETDB_STORE_TYPE_LEASESET; }; + virtual uint8_t GetOrigStoreType () const { return NETDB_STORE_TYPE_LEASESET; }; virtual uint32_t GetPublishedTimestamp () const { return 0; }; // should be set for LeaseSet2 only virtual std::shared_ptr GetTransientVerifier () const { return nullptr; }; @@ -165,6 +166,7 @@ namespace data LeaseSet2 (uint8_t storeType, const uint8_t * buf, size_t len, bool storeLeases = true); LeaseSet2 (const uint8_t * buf, size_t len, std::shared_ptr key); // store type 5, called from local netdb only uint8_t GetStoreType () const { return m_StoreType; }; + uint8_t GetOrigStoreType () const { return m_OrigStoreType; }; uint32_t GetPublishedTimestamp () const { return m_PublishedTimestamp; }; std::shared_ptr GetTransientVerifier () const { return m_TransientVerifier; }; void Update (const uint8_t * buf, size_t len, bool verifySignature); @@ -186,7 +188,7 @@ namespace data private: - uint8_t m_StoreType; + uint8_t m_StoreType, m_OrigStoreType; uint32_t m_PublishedTimestamp = 0; std::shared_ptr m_TransientVerifier; std::shared_ptr m_Encryptor; // for standardLS2 diff --git a/libi2pd/Streaming.cpp b/libi2pd/Streaming.cpp index 226cd4f6..7b1f187b 100644 --- a/libi2pd/Streaming.cpp +++ b/libi2pd/Streaming.cpp @@ -917,7 +917,12 @@ namespace stream if (leases.empty ()) { expired = false; - m_LocalDestination.GetOwner ()->RequestDestination (m_RemoteIdentity->GetIdentHash ()); // time to request + // time to request + if (m_RemoteLeaseSet->GetOrigStoreType () == i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2) + m_LocalDestination.GetOwner ()->RequestDestinationWithEncryptedLeaseSet ( + std::make_shared(m_RemoteIdentity)); + else + m_LocalDestination.GetOwner ()->RequestDestination (m_RemoteIdentity->GetIdentHash ()); leases = m_RemoteLeaseSet->GetNonExpiredLeases (true); // then with threshold } if (!leases.empty ())