|
|
@ -450,8 +450,16 @@ namespace data |
|
|
|
// do we have that floodfill router in our database?
|
|
|
|
// do we have that floodfill router in our database?
|
|
|
|
if (r) |
|
|
|
if (r) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// we do
|
|
|
|
if (!dest->IsExcluded (r->GetIdentHash ()) && dest->GetNumExcludedPeers () < 30) // TODO: fix TunnelGateway first
|
|
|
|
if (!dest->IsExcluded (r->GetIdentHash ()) && dest->GetNumExcludedPeers () < 30) // TODO: fix TunnelGateway first
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
// tell floodfill about us
|
|
|
|
|
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
i2p::tunnel::eDeliveryTypeRouter, |
|
|
|
|
|
|
|
r->GetIdentHash (), 0, |
|
|
|
|
|
|
|
CreateDatabaseStoreMsg () |
|
|
|
|
|
|
|
}); |
|
|
|
// request destination
|
|
|
|
// request destination
|
|
|
|
auto msg = dest->CreateRequestMessage (r, dest->GetLastReplyTunnel ()); |
|
|
|
auto msg = dest->CreateRequestMessage (r, dest->GetLastReplyTunnel ()); |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
@ -506,16 +514,15 @@ namespace data |
|
|
|
auto inbound = i2p::tunnel::tunnels.GetNextInboundTunnel (); |
|
|
|
auto inbound = i2p::tunnel::tunnels.GetNextInboundTunnel (); |
|
|
|
if (outbound && inbound) |
|
|
|
if (outbound && inbound) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto floodfill = GetRandomRouter (outbound->GetEndpointRouter (), true); |
|
|
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); |
|
|
|
|
|
|
|
uint8_t randomHash[32]; |
|
|
|
|
|
|
|
rnd.GenerateBlock (randomHash, 32); |
|
|
|
|
|
|
|
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true); |
|
|
|
|
|
|
|
dest->SetLastOutboundTunnel (outbound); |
|
|
|
|
|
|
|
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ()); |
|
|
|
if (floodfill) |
|
|
|
if (floodfill) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Exploring new routers ..."); |
|
|
|
LogPrint ("Exploring new routers ..."); |
|
|
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); |
|
|
|
|
|
|
|
uint8_t randomHash[32]; |
|
|
|
|
|
|
|
rnd.GenerateBlock (randomHash, 32); |
|
|
|
|
|
|
|
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true); |
|
|
|
|
|
|
|
dest->SetLastOutboundTunnel (outbound); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
{ |
|
|
|
{ |
|
|
@ -531,6 +538,8 @@ namespace data |
|
|
|
}); |
|
|
|
}); |
|
|
|
outbound->SendTunnelDataMsg (msgs); |
|
|
|
outbound->SendTunnelDataMsg (msgs); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
DeleteRequestedDestination (dest); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -558,6 +567,15 @@ namespace data |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void NetDb::DeleteRequestedDestination (RequestedDestination * dest) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (dest) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_RequestedDestinations.erase (dest->GetDestination ()); |
|
|
|
|
|
|
|
delete dest; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const RouterInfo * NetDb::GetRandomNTCPRouter (bool floodfillOnly) const |
|
|
|
const RouterInfo * NetDb::GetRandomNTCPRouter (bool floodfillOnly) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); |
|
|
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); |
|
|
|