|
|
@ -361,8 +361,10 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
i2p::data::IdentHash key (buf + DATABASE_STORE_KEY_OFFSET); |
|
|
|
i2p::data::IdentHash key (buf + DATABASE_STORE_KEY_OFFSET); |
|
|
|
std::shared_ptr<i2p::data::LeaseSet> leaseSet; |
|
|
|
std::shared_ptr<i2p::data::LeaseSet> leaseSet; |
|
|
|
if (buf[DATABASE_STORE_TYPE_OFFSET] == i2p::data::NETDB_STORE_TYPE_LEASESET || // 1
|
|
|
|
switch (buf[DATABASE_STORE_TYPE_OFFSET]) |
|
|
|
buf[DATABASE_STORE_TYPE_OFFSET] == i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2) // 3
|
|
|
|
{ |
|
|
|
|
|
|
|
case i2p::data::NETDB_STORE_TYPE_LEASESET: // 1
|
|
|
|
|
|
|
|
case i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2: // 3
|
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogDebug, "Destination: Remote LeaseSet"); |
|
|
|
LogPrint (eLogDebug, "Destination: Remote LeaseSet"); |
|
|
|
std::lock_guard<std::mutex> lock(m_RemoteLeaseSetsMutex); |
|
|
|
std::lock_guard<std::mutex> lock(m_RemoteLeaseSetsMutex); |
|
|
@ -407,9 +409,27 @@ namespace client |
|
|
|
leaseSet = nullptr; |
|
|
|
leaseSet = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
case i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2: // 5
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto it2 = m_LeaseSetRequests.find (key); |
|
|
|
|
|
|
|
if (it2 != m_LeaseSetRequests.end () && it2->second->requestedIdentity) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto ls2 = std::make_shared<i2p::data::LeaseSet2> (buf + offset, len - offset, it2->second->requestedIdentity); |
|
|
|
|
|
|
|
if (ls2->IsValid ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_RemoteLeaseSets[ls2->GetIdentHash ()] = ls2; // ident is not key
|
|
|
|
|
|
|
|
leaseSet = ls2; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
LogPrint (eLogInfo, "Destination: Couldn't find request for encrypted LeaseSet2"); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
default: |
|
|
|
LogPrint (eLogError, "Destination: Unexpected client's DatabaseStore type ", buf[DATABASE_STORE_TYPE_OFFSET], ", dropped"); |
|
|
|
LogPrint (eLogError, "Destination: Unexpected client's DatabaseStore type ", buf[DATABASE_STORE_TYPE_OFFSET], ", dropped"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto it1 = m_LeaseSetRequests.find (key); |
|
|
|
auto it1 = m_LeaseSetRequests.find (key); |
|
|
|
if (it1 != m_LeaseSetRequests.end ()) |
|
|
|
if (it1 != m_LeaseSetRequests.end ()) |
|
|
@ -605,7 +625,21 @@ namespace client |
|
|
|
m_Service.post ([requestComplete](void){requestComplete (nullptr);}); |
|
|
|
m_Service.post ([requestComplete](void){requestComplete (nullptr);}); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
m_Service.post (std::bind (&LeaseSetDestination::RequestLeaseSet, shared_from_this (), dest, requestComplete)); |
|
|
|
m_Service.post (std::bind (&LeaseSetDestination::RequestLeaseSet, shared_from_this (), dest, requestComplete, nullptr)); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LeaseSetDestination::RequestDestinationWithEncryptedLeaseSet (std::shared_ptr<const i2p::data::IdentityEx> dest, RequestComplete requestComplete) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!m_Pool || !IsReady ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (requestComplete) |
|
|
|
|
|
|
|
m_Service.post ([requestComplete](void){requestComplete (nullptr);}); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
i2p::data::IdentHash ident; |
|
|
|
|
|
|
|
i2p::data::LeaseSet2::CalculateStoreHash (dest, i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519, ident); // always assume type 11
|
|
|
|
|
|
|
|
m_Service.post (std::bind (&LeaseSetDestination::RequestLeaseSet, shared_from_this (), ident, requestComplete, dest)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -624,13 +658,21 @@ namespace client |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void LeaseSetDestination::RequestLeaseSet (const i2p::data::IdentHash& dest, RequestComplete requestComplete) |
|
|
|
void LeaseSetDestination::CancelDestinationRequestWithEncryptedLeaseSet (std::shared_ptr<const i2p::data::IdentityEx> dest, bool notify) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
i2p::data::IdentHash ident; |
|
|
|
|
|
|
|
i2p::data::LeaseSet2::CalculateStoreHash (dest, i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519, ident); // always assume type 11
|
|
|
|
|
|
|
|
CancelDestinationRequest (ident, notify); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LeaseSetDestination::RequestLeaseSet (const i2p::data::IdentHash& dest, RequestComplete requestComplete, std::shared_ptr<const i2p::data::IdentityEx> requestedIdentity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::set<i2p::data::IdentHash> excluded; |
|
|
|
std::set<i2p::data::IdentHash> excluded; |
|
|
|
auto floodfill = i2p::data::netdb.GetClosestFloodfill (dest, excluded); |
|
|
|
auto floodfill = i2p::data::netdb.GetClosestFloodfill (dest, excluded); |
|
|
|
if (floodfill) |
|
|
|
if (floodfill) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto request = std::make_shared<LeaseSetRequest> (m_Service); |
|
|
|
auto request = std::make_shared<LeaseSetRequest> (m_Service); |
|
|
|
|
|
|
|
request->requestedIdentity = requestedIdentity; // for encrypted LeaseSet2
|
|
|
|
if (requestComplete) |
|
|
|
if (requestComplete) |
|
|
|
request->requestComplete.push_back (requestComplete); |
|
|
|
request->requestComplete.push_back (requestComplete); |
|
|
|
auto ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
auto ts = i2p::util::GetSecondsSinceEpoch (); |
|
|
|