|
|
@ -213,7 +213,7 @@ namespace client |
|
|
|
return pool->Reconfigure(inLen, outLen, inQuant, outQuant); |
|
|
|
return pool->Reconfigure(inLen, outLen, inQuant, outQuant); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<const i2p::data::LeaseSet> LeaseSetDestination::FindLeaseSet (const i2p::data::IdentHash& ident) |
|
|
|
std::shared_ptr<i2p::data::LeaseSet> LeaseSetDestination::FindLeaseSet (const i2p::data::IdentHash& ident) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::shared_ptr<i2p::data::LeaseSet> remoteLS; |
|
|
|
std::shared_ptr<i2p::data::LeaseSet> remoteLS; |
|
|
|
{ |
|
|
|
{ |
|
|
@ -425,6 +425,7 @@ namespace client |
|
|
|
if (ls2->IsValid ()) |
|
|
|
if (ls2->IsValid ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_RemoteLeaseSets[ls2->GetIdentHash ()] = ls2; // ident is not key
|
|
|
|
m_RemoteLeaseSets[ls2->GetIdentHash ()] = ls2; // ident is not key
|
|
|
|
|
|
|
|
m_RemoteLeaseSets[key] = ls2; // also store as key for next lookup
|
|
|
|
leaseSet = ls2; |
|
|
|
leaseSet = ls2; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -594,7 +595,7 @@ namespace client |
|
|
|
auto s = shared_from_this (); |
|
|
|
auto s = shared_from_this (); |
|
|
|
RequestLeaseSet (GetIdentHash (), |
|
|
|
RequestLeaseSet (GetIdentHash (), |
|
|
|
// "this" added due to bug in gcc 4.7-4.8
|
|
|
|
// "this" added due to bug in gcc 4.7-4.8
|
|
|
|
[s,this](std::shared_ptr<i2p::data::LeaseSet> leaseSet) |
|
|
|
[s,this](std::shared_ptr<const i2p::data::LeaseSet> leaseSet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (leaseSet) |
|
|
|
if (leaseSet) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -636,7 +637,7 @@ namespace client |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool LeaseSetDestination::RequestDestinationWithEncryptedLeaseSet (std::shared_ptr<const i2p::data::IdentityEx> dest, RequestComplete requestComplete) |
|
|
|
bool LeaseSetDestination::RequestDestinationWithEncryptedLeaseSet (std::shared_ptr<const i2p::data::BlindedPublicKey> dest, RequestComplete requestComplete) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_Pool || !IsReady ()) |
|
|
|
if (!m_Pool || !IsReady ()) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -644,10 +645,16 @@ namespace client |
|
|
|
m_Service.post ([requestComplete](void){requestComplete (nullptr);}); |
|
|
|
m_Service.post ([requestComplete](void){requestComplete (nullptr);}); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
auto blindedKey = std::make_shared<i2p::data::BlindedPublicKey>(dest, i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519); // always assume type 11
|
|
|
|
i2p::data::IdentHash storeKey; |
|
|
|
i2p::data::IdentHash ident; |
|
|
|
i2p::data::LeaseSet2::CalculateStoreHash (dest, storeKey); |
|
|
|
i2p::data::LeaseSet2::CalculateStoreHash (blindedKey, ident); |
|
|
|
auto leaseSet = FindLeaseSet (storeKey); |
|
|
|
m_Service.post (std::bind (&LeaseSetDestination::RequestLeaseSet, shared_from_this (), ident, requestComplete, blindedKey)); |
|
|
|
if (leaseSet) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (requestComplete) |
|
|
|
|
|
|
|
m_Service.post ([requestComplete, leaseSet](void){requestComplete (leaseSet);}); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
m_Service.post (std::bind (&LeaseSetDestination::RequestLeaseSet, shared_from_this (), storeKey, requestComplete, dest)); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -666,11 +673,10 @@ namespace client |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void LeaseSetDestination::CancelDestinationRequestWithEncryptedLeaseSet (std::shared_ptr<const i2p::data::IdentityEx> dest, bool notify) |
|
|
|
void LeaseSetDestination::CancelDestinationRequestWithEncryptedLeaseSet (std::shared_ptr<const i2p::data::BlindedPublicKey> dest, bool notify) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto blindedKey = std::make_shared<i2p::data::BlindedPublicKey>(dest, i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519); // always assume type 11
|
|
|
|
|
|
|
|
i2p::data::IdentHash ident; |
|
|
|
i2p::data::IdentHash ident; |
|
|
|
i2p::data::LeaseSet2::CalculateStoreHash (blindedKey, ident); |
|
|
|
i2p::data::LeaseSet2::CalculateStoreHash (dest, ident); |
|
|
|
CancelDestinationRequest (ident, notify); |
|
|
|
CancelDestinationRequest (ident, notify); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -976,7 +982,7 @@ namespace client |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto s = GetSharedFromThis (); |
|
|
|
auto s = GetSharedFromThis (); |
|
|
|
RequestDestination (dest, |
|
|
|
RequestDestination (dest, |
|
|
|
[s, streamRequestComplete, port](std::shared_ptr<i2p::data::LeaseSet> ls) |
|
|
|
[s, streamRequestComplete, port](std::shared_ptr<const i2p::data::LeaseSet> ls) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ls) |
|
|
|
if (ls) |
|
|
|
streamRequestComplete(s->CreateStream (ls, port)); |
|
|
|
streamRequestComplete(s->CreateStream (ls, port)); |
|
|
@ -986,6 +992,24 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, std::shared_ptr<const i2p::data::BlindedPublicKey> dest, int port) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!streamRequestComplete) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogError, "Destination: request callback is not specified in CreateStream"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
auto s = GetSharedFromThis (); |
|
|
|
|
|
|
|
RequestDestinationWithEncryptedLeaseSet (dest, |
|
|
|
|
|
|
|
[s, streamRequestComplete, port](std::shared_ptr<i2p::data::LeaseSet> ls) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (ls) |
|
|
|
|
|
|
|
streamRequestComplete(s->CreateStream (ls, port)); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
streamRequestComplete (nullptr); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (std::shared_ptr<const i2p::data::LeaseSet> remote, int port) |
|
|
|
std::shared_ptr<i2p::stream::Stream> ClientDestination::CreateStream (std::shared_ptr<const i2p::data::LeaseSet> remote, int port) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_StreamingDestination) |
|
|
|
if (m_StreamingDestination) |
|
|
|