|
|
@ -37,7 +37,7 @@ namespace client |
|
|
|
int inVar = DEFAULT_INBOUND_TUNNELS_LENGTH_VARIANCE; |
|
|
|
int inVar = DEFAULT_INBOUND_TUNNELS_LENGTH_VARIANCE; |
|
|
|
int outVar = DEFAULT_OUTBOUND_TUNNELS_LENGTH_VARIANCE; |
|
|
|
int outVar = DEFAULT_OUTBOUND_TUNNELS_LENGTH_VARIANCE; |
|
|
|
int numTags = DEFAULT_TAGS_TO_SEND; |
|
|
|
int numTags = DEFAULT_TAGS_TO_SEND; |
|
|
|
bool isHighBandwidth = true; |
|
|
|
bool isHighBandwidth = true; |
|
|
|
std::shared_ptr<std::vector<i2p::data::IdentHash> > explicitPeers; |
|
|
|
std::shared_ptr<std::vector<i2p::data::IdentHash> > explicitPeers; |
|
|
|
try |
|
|
|
try |
|
|
|
{ |
|
|
|
{ |
|
|
@ -471,7 +471,7 @@ namespace client |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto it2 = m_LeaseSetRequests.find (key); |
|
|
|
auto it2 = m_LeaseSetRequests.find (key); |
|
|
|
if (it2 != m_LeaseSetRequests.end ()) |
|
|
|
if (it2 != m_LeaseSetRequests.end ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
request = it2->second; |
|
|
|
request = it2->second; |
|
|
|
m_LeaseSetRequests.erase (it2); |
|
|
|
m_LeaseSetRequests.erase (it2); |
|
|
|
if (request->requestedBlindedKey) |
|
|
|
if (request->requestedBlindedKey) |
|
|
@ -493,14 +493,14 @@ namespace client |
|
|
|
// publishing verification doesn't have requestedBlindedKey
|
|
|
|
// publishing verification doesn't have requestedBlindedKey
|
|
|
|
auto localLeaseSet = GetLeaseSetMt (); |
|
|
|
auto localLeaseSet = GetLeaseSetMt (); |
|
|
|
if (localLeaseSet->GetStoreHash () == key) |
|
|
|
if (localLeaseSet->GetStoreHash () == key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto ls = std::make_shared<i2p::data::LeaseSet2> (i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2, |
|
|
|
auto ls = std::make_shared<i2p::data::LeaseSet2> (i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2, |
|
|
|
localLeaseSet->GetBuffer (), localLeaseSet->GetBufferLen (), false); |
|
|
|
localLeaseSet->GetBuffer (), localLeaseSet->GetBufferLen (), false); |
|
|
|
leaseSet = ls; |
|
|
|
leaseSet = ls; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogWarning, "Destination: Encrypted LeaseSet2 received for request without blinded key"); |
|
|
|
LogPrint (eLogWarning, "Destination: Encrypted LeaseSet2 received for request without blinded key"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogWarning, "Destination: Couldn't find request for encrypted LeaseSet2"); |
|
|
|
LogPrint (eLogWarning, "Destination: Couldn't find request for encrypted LeaseSet2"); |
|
|
@ -511,14 +511,14 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!request) |
|
|
|
if (!request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto it1 = m_LeaseSetRequests.find (key); |
|
|
|
auto it1 = m_LeaseSetRequests.find (key); |
|
|
|
if (it1 != m_LeaseSetRequests.end ()) |
|
|
|
if (it1 != m_LeaseSetRequests.end ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
request = it1->second; |
|
|
|
request = it1->second; |
|
|
|
m_LeaseSetRequests.erase (it1); |
|
|
|
m_LeaseSetRequests.erase (it1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (request) |
|
|
|
if (request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
request->requestTimeoutTimer.cancel (); |
|
|
|
request->requestTimeoutTimer.cancel (); |
|
|
@ -550,7 +550,7 @@ namespace client |
|
|
|
LogPrint (eLogWarning, "Destination: Request for ", key.ToBase64 (), " not found"); |
|
|
|
LogPrint (eLogWarning, "Destination: Request for ", key.ToBase64 (), " not found"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void LeaseSetDestination::SendNextLeaseSetRequest (const i2p::data::IdentHash& key, |
|
|
|
void LeaseSetDestination::SendNextLeaseSetRequest (const i2p::data::IdentHash& key, |
|
|
|
std::shared_ptr<LeaseSetRequest> request) |
|
|
|
std::shared_ptr<LeaseSetRequest> request) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool found = false; |
|
|
|
bool found = false; |
|
|
@ -570,8 +570,8 @@ namespace client |
|
|
|
request->Complete (nullptr); |
|
|
|
request->Complete (nullptr); |
|
|
|
m_LeaseSetRequests.erase (key); |
|
|
|
m_LeaseSetRequests.erase (key); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void LeaseSetDestination::HandleDeliveryStatusMessage (uint32_t msgID) |
|
|
|
void LeaseSetDestination::HandleDeliveryStatusMessage (uint32_t msgID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (msgID == m_PublishReplyToken) |
|
|
|
if (msgID == m_PublishReplyToken) |
|
|
@ -592,7 +592,7 @@ namespace client |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (post) |
|
|
|
if (post) |
|
|
|
m_Service.post([s = shared_from_this ()]() { s->UpdateLeaseSet (); }); |
|
|
|
m_Service.post([s = shared_from_this ()]() { s->UpdateLeaseSet (); }); |
|
|
|
else |
|
|
|
else |
|
|
|
UpdateLeaseSet (); |
|
|
|
UpdateLeaseSet (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -631,7 +631,7 @@ namespace client |
|
|
|
if (!outbound || !inbound) |
|
|
|
if (!outbound || !inbound) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_Pool->GetInboundTunnels ().empty () && !m_Pool->GetOutboundTunnels ().empty ()) |
|
|
|
if (!m_Pool->GetInboundTunnels ().empty () && !m_Pool->GetOutboundTunnels ().empty ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogInfo, "Destination: No compatible tunnels with ", floodfill->GetIdentHash ().ToBase64 (), ". Trying another floodfill"); |
|
|
|
LogPrint (eLogInfo, "Destination: No compatible tunnels with ", floodfill->GetIdentHash ().ToBase64 (), ". Trying another floodfill"); |
|
|
|
m_ExcludedFloodfills.insert (floodfill->GetIdentHash ()); |
|
|
|
m_ExcludedFloodfills.insert (floodfill->GetIdentHash ()); |
|
|
|
floodfill = i2p::data::netdb.GetClosestFloodfill (leaseSet->GetStoreHash (), m_ExcludedFloodfills); |
|
|
|
floodfill = i2p::data::netdb.GetClosestFloodfill (leaseSet->GetStoreHash (), m_ExcludedFloodfills); |
|
|
@ -649,10 +649,10 @@ namespace client |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogError, "Destination: Can't publish LeaseSet, no more floodfills found"); |
|
|
|
LogPrint (eLogError, "Destination: Can't publish LeaseSet, no more floodfills found"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogDebug, "Destination: No tunnels in pool"); |
|
|
|
LogPrint (eLogDebug, "Destination: No tunnels in pool"); |
|
|
|
|
|
|
|
|
|
|
|
if (!floodfill || !outbound || !inbound) |
|
|
|
if (!floodfill || !outbound || !inbound) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// we can't publish now
|
|
|
|
// we can't publish now
|
|
|
@ -880,8 +880,8 @@ namespace client |
|
|
|
AddECIESx25519Key (replyKey, replyTag); |
|
|
|
AddECIESx25519Key (replyKey, replyTag); |
|
|
|
else |
|
|
|
else |
|
|
|
AddSessionKey (replyKey, replyTag); |
|
|
|
AddSessionKey (replyKey, replyTag); |
|
|
|
|
|
|
|
|
|
|
|
auto msg = WrapMessageForRouter (nextFloodfill, |
|
|
|
auto msg = WrapMessageForRouter (nextFloodfill, |
|
|
|
CreateLeaseSetDatabaseLookupMsg (dest, request->excluded, request->replyTunnel, replyKey, replyTag, isECIES)); |
|
|
|
CreateLeaseSetDatabaseLookupMsg (dest, request->excluded, request->replyTunnel, replyKey, replyTag, isECIES)); |
|
|
|
auto s = shared_from_this (); |
|
|
|
auto s = shared_from_this (); |
|
|
|
msg->onDrop = [s, dest, request]() |
|
|
|
msg->onDrop = [s, dest, request]() |
|
|
@ -890,7 +890,7 @@ namespace client |
|
|
|
{ |
|
|
|
{ |
|
|
|
s->SendNextLeaseSetRequest (dest, request); |
|
|
|
s->SendNextLeaseSetRequest (dest, request); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
}; |
|
|
|
request->outboundTunnel->SendTunnelDataMsgs ( |
|
|
|
request->outboundTunnel->SendTunnelDataMsgs ( |
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::tunnel::TunnelMessageBlock |
|
|
|
i2p::tunnel::TunnelMessageBlock |
|
|
@ -988,7 +988,7 @@ namespace client |
|
|
|
m_Keys (keys), m_StreamingAckDelay (DEFAULT_INITIAL_ACK_DELAY), |
|
|
|
m_Keys (keys), m_StreamingAckDelay (DEFAULT_INITIAL_ACK_DELAY), |
|
|
|
m_StreamingOutboundSpeed (DEFAULT_MAX_OUTBOUND_SPEED), |
|
|
|
m_StreamingOutboundSpeed (DEFAULT_MAX_OUTBOUND_SPEED), |
|
|
|
m_StreamingInboundSpeed (DEFAULT_MAX_INBOUND_SPEED), |
|
|
|
m_StreamingInboundSpeed (DEFAULT_MAX_INBOUND_SPEED), |
|
|
|
m_StreamingMaxConcurrentStreams (DEFAULT_MAX_CONCURRENT_STREAMS), |
|
|
|
m_StreamingMaxConcurrentStreams (DEFAULT_MAX_CONCURRENT_STREAMS), |
|
|
|
m_IsStreamingAnswerPings (DEFAULT_ANSWER_PINGS), m_LastPort (0), |
|
|
|
m_IsStreamingAnswerPings (DEFAULT_ANSWER_PINGS), m_LastPort (0), |
|
|
|
m_DatagramDestination (nullptr), m_RefCounter (0), m_LastPublishedTimestamp (0), |
|
|
|
m_DatagramDestination (nullptr), m_RefCounter (0), m_LastPublishedTimestamp (0), |
|
|
|
m_ReadyChecker(service) |
|
|
|
m_ReadyChecker(service) |
|
|
@ -1441,11 +1441,11 @@ namespace client |
|
|
|
keySections.push_back ({m_StandardEncryptionKey->keyType, (uint16_t)m_StandardEncryptionKey->decryptor->GetPublicKeyLen (), m_StandardEncryptionKey->pub} ); |
|
|
|
keySections.push_back ({m_StandardEncryptionKey->keyType, (uint16_t)m_StandardEncryptionKey->decryptor->GetPublicKeyLen (), m_StandardEncryptionKey->pub} ); |
|
|
|
|
|
|
|
|
|
|
|
auto publishedTimestamp = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
auto publishedTimestamp = i2p::util::GetSecondsSinceEpoch (); |
|
|
|
if (publishedTimestamp <= m_LastPublishedTimestamp) |
|
|
|
if (publishedTimestamp <= m_LastPublishedTimestamp) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogDebug, "Destination: LeaseSet update at the same second"); |
|
|
|
LogPrint (eLogDebug, "Destination: LeaseSet update at the same second"); |
|
|
|
publishedTimestamp++; // force newer timestamp
|
|
|
|
publishedTimestamp++; // force newer timestamp
|
|
|
|
} |
|
|
|
} |
|
|
|
bool isPublishedEncrypted = GetLeaseSetType () == i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2; |
|
|
|
bool isPublishedEncrypted = GetLeaseSetType () == i2p::data::NETDB_STORE_TYPE_ENCRYPTED_LEASESET2; |
|
|
|
auto ls2 = std::make_shared<i2p::data::LocalLeaseSet2> (i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2, |
|
|
|
auto ls2 = std::make_shared<i2p::data::LocalLeaseSet2> (i2p::data::NETDB_STORE_TYPE_STANDARD_LEASESET2, |
|
|
|
m_Keys, keySections, tunnels, IsPublic (), publishedTimestamp, isPublishedEncrypted); |
|
|
|
m_Keys, keySections, tunnels, IsPublic (), publishedTimestamp, isPublishedEncrypted); |
|
|
@ -1517,6 +1517,8 @@ namespace client |
|
|
|
RunnableService ("Destination"), |
|
|
|
RunnableService ("Destination"), |
|
|
|
ClientDestination (GetIOService (), keys, isPublic, params) |
|
|
|
ClientDestination (GetIOService (), keys, isPublic, params) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!GetNickname ().empty ()) |
|
|
|
|
|
|
|
RunnableService::SetName (GetNickname ()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RunnableClientDestination::~RunnableClientDestination () |
|
|
|
RunnableClientDestination::~RunnableClientDestination () |
|
|
|