|
|
@ -610,7 +610,7 @@ namespace data |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NetDb::RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete) |
|
|
|
void NetDb::RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete, bool direct) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto dest = m_Requests.CreateRequest (destination, false, requestComplete); // non-exploratory
|
|
|
|
auto dest = m_Requests.CreateRequest (destination, false, requestComplete); // non-exploratory
|
|
|
|
if (!dest) |
|
|
|
if (!dest) |
|
|
@ -621,8 +621,24 @@ namespace data |
|
|
|
|
|
|
|
|
|
|
|
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ()); |
|
|
|
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ()); |
|
|
|
if (floodfill) |
|
|
|
if (floodfill) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (direct) |
|
|
|
transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ())); |
|
|
|
transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ())); |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto pool = i2p::tunnel::tunnels.GetExploratoryPool (); |
|
|
|
|
|
|
|
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr; |
|
|
|
|
|
|
|
auto inbound = pool ? pool->GetNextInboundTunnel () : nullptr; |
|
|
|
|
|
|
|
if (outbound && inbound) |
|
|
|
|
|
|
|
outbound->SendTunnelDataMsg (floodfill->GetIdentHash (), 0, dest->CreateRequestMessage (floodfill, inbound)); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogError, "NetDb: ", destination.ToBase64(), " destination requested, but no tunnels found"); |
|
|
|
|
|
|
|
m_Requests.RequestComplete (destination, nullptr); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "NetDb: ", destination.ToBase64(), " destination requested, but no floodfills found"); |
|
|
|
LogPrint (eLogError, "NetDb: ", destination.ToBase64(), " destination requested, but no floodfills found"); |
|
|
|
m_Requests.RequestComplete (destination, nullptr); |
|
|
|
m_Requests.RequestComplete (destination, nullptr); |
|
|
@ -775,37 +791,21 @@ namespace data |
|
|
|
// reply to our destination. Try other floodfills
|
|
|
|
// reply to our destination. Try other floodfills
|
|
|
|
if (outbound && inbound) |
|
|
|
if (outbound && inbound) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
|
|
|
|
|
auto count = dest->GetExcludedPeers ().size (); |
|
|
|
auto count = dest->GetExcludedPeers ().size (); |
|
|
|
if (count < 7) |
|
|
|
if (count < 7) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto nextFloodfill = GetClosestFloodfill (dest->GetDestination (), dest->GetExcludedPeers ()); |
|
|
|
auto nextFloodfill = GetClosestFloodfill (dest->GetDestination (), dest->GetExcludedPeers ()); |
|
|
|
if (nextFloodfill) |
|
|
|
if (nextFloodfill) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// tell floodfill about us
|
|
|
|
|
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
i2p::tunnel::eDeliveryTypeRouter, |
|
|
|
|
|
|
|
nextFloodfill->GetIdentHash (), 0, |
|
|
|
|
|
|
|
CreateDatabaseStoreMsg () |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// request destination
|
|
|
|
// request destination
|
|
|
|
LogPrint (eLogDebug, "NetDb: Try ", key, " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 ()); |
|
|
|
LogPrint (eLogDebug, "NetDb: Try ", key, " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 ()); |
|
|
|
auto msg = dest->CreateRequestMessage (nextFloodfill, inbound); |
|
|
|
outbound->SendTunnelDataMsg (nextFloodfill->GetIdentHash (), 0, |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
dest->CreateRequestMessage (nextFloodfill, inbound)); |
|
|
|
{ |
|
|
|
|
|
|
|
i2p::tunnel::eDeliveryTypeRouter, |
|
|
|
|
|
|
|
nextFloodfill->GetIdentHash (), 0, msg |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
deleteDest = false; |
|
|
|
deleteDest = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint (eLogWarning, "NetDb: ", key, " was not found on ", count, " floodfills"); |
|
|
|
LogPrint (eLogWarning, "NetDb: ", key, " was not found on ", count, " floodfills"); |
|
|
|
|
|
|
|
|
|
|
|
if (msgs.size () > 0) |
|
|
|
|
|
|
|
outbound->SendTunnelDataMsg (msgs); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|