|
|
@ -355,17 +355,17 @@ namespace data |
|
|
|
LogPrint (deletedCount," routers deleted"); |
|
|
|
LogPrint (deletedCount," routers deleted"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NetDb::RequestDestination (const IdentHash& destination, bool isLeaseSet) |
|
|
|
void NetDb::RequestDestination (const IdentHash& destination, bool isLeaseSet, i2p::tunnel::TunnelPool * pool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (isLeaseSet) // we request LeaseSet through tunnels
|
|
|
|
if (isLeaseSet) // we request LeaseSet through tunnels
|
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::tunnel::OutboundTunnel * outbound = i2p::tunnel::tunnels.GetNextOutboundTunnel (); |
|
|
|
i2p::tunnel::OutboundTunnel * outbound = pool ? pool->GetNextOutboundTunnel () : i2p::tunnel::tunnels.GetNextOutboundTunnel (); |
|
|
|
if (outbound) |
|
|
|
if (outbound) |
|
|
|
{ |
|
|
|
{ |
|
|
|
i2p::tunnel::InboundTunnel * inbound = i2p::tunnel::tunnels.GetNextInboundTunnel (); |
|
|
|
i2p::tunnel::InboundTunnel * inbound = pool ? pool->GetNextInboundTunnel () :i2p::tunnel::tunnels.GetNextInboundTunnel (); |
|
|
|
if (inbound) |
|
|
|
if (inbound) |
|
|
|
{ |
|
|
|
{ |
|
|
|
RequestedDestination * dest = CreateRequestedDestination (destination, isLeaseSet); |
|
|
|
RequestedDestination * dest = CreateRequestedDestination (destination, isLeaseSet, pool); |
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
|
// request 3 closests floodfills
|
|
|
|
// request 3 closests floodfills
|
|
|
|
for (int i = 0; i < 3; i++) |
|
|
|
for (int i = 0; i < 3; i++) |
|
|
@ -398,7 +398,7 @@ namespace data |
|
|
|
} |
|
|
|
} |
|
|
|
else // RouterInfo is requested directly
|
|
|
|
else // RouterInfo is requested directly
|
|
|
|
{ |
|
|
|
{ |
|
|
|
RequestedDestination * dest = CreateRequestedDestination (destination, false); |
|
|
|
RequestedDestination * dest = CreateRequestedDestination (destination, false, pool); |
|
|
|
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ()); |
|
|
|
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ()); |
|
|
|
if (floodfill) |
|
|
|
if (floodfill) |
|
|
|
i2p::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ())); |
|
|
|
i2p::transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ())); |
|
|
@ -451,7 +451,9 @@ namespace data |
|
|
|
bool deleteDest = true; |
|
|
|
bool deleteDest = true; |
|
|
|
if (num > 0) |
|
|
|
if (num > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool (); |
|
|
|
auto exploratoryPool = dest ? dest->GetTunnelPool () : nullptr; |
|
|
|
|
|
|
|
if (!exploratoryPool) |
|
|
|
|
|
|
|
exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool (); |
|
|
|
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr; |
|
|
|
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr; |
|
|
|
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr; |
|
|
|
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr; |
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
@ -473,7 +475,7 @@ namespace data |
|
|
|
LogPrint ("Found new/outdated router. Requesting RouterInfo ..."); |
|
|
|
LogPrint ("Found new/outdated router. Requesting RouterInfo ..."); |
|
|
|
if (outbound && inbound && dest->GetLastRouter ()) |
|
|
|
if (outbound && inbound && dest->GetLastRouter ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
RequestedDestination * d1 = CreateRequestedDestination (router, false, false); |
|
|
|
RequestedDestination * d1 = CreateRequestedDestination (router, false, false, exploratoryPool); |
|
|
|
auto msg = d1->CreateRequestMessage (dest->GetLastRouter (), inbound); |
|
|
|
auto msg = d1->CreateRequestMessage (dest->GetLastRouter (), inbound); |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
{ |
|
|
|
{ |
|
|
@ -519,7 +521,7 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
// request router
|
|
|
|
// request router
|
|
|
|
LogPrint ("Found new floodfill. Request it"); |
|
|
|
LogPrint ("Found new floodfill. Request it"); |
|
|
|
RequestedDestination * d2 = CreateRequestedDestination (router, false, false); |
|
|
|
RequestedDestination * d2 = CreateRequestedDestination (router, false, false, exploratoryPool); |
|
|
|
I2NPMessage * msg = d2->CreateRequestMessage (dest->GetLastRouter (), inbound); |
|
|
|
I2NPMessage * msg = d2->CreateRequestMessage (dest->GetLastRouter (), inbound); |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock |
|
|
|
{ |
|
|
|
{ |
|
|
@ -689,7 +691,7 @@ namespace data |
|
|
|
for (int i = 0; i < numDestinations; i++) |
|
|
|
for (int i = 0; i < numDestinations; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
rnd.GenerateBlock (randomHash, 32); |
|
|
|
rnd.GenerateBlock (randomHash, 32); |
|
|
|
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true); |
|
|
|
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true, exploratoryPool); |
|
|
|
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ()); |
|
|
|
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ()); |
|
|
|
if (floodfill && !floodfills.count (floodfill)) // request floodfill only once
|
|
|
|
if (floodfill && !floodfills.count (floodfill)) // request floodfill only once
|
|
|
|
{ |
|
|
|
{ |
|
|
@ -735,12 +737,12 @@ namespace data |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RequestedDestination * NetDb::CreateRequestedDestination (const IdentHash& dest, |
|
|
|
RequestedDestination * NetDb::CreateRequestedDestination (const IdentHash& dest, |
|
|
|
bool isLeaseSet, bool isExploratory) |
|
|
|
bool isLeaseSet, bool isExploratory, i2p::tunnel::TunnelPool * pool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto it = m_RequestedDestinations.find (dest); |
|
|
|
auto it = m_RequestedDestinations.find (dest); |
|
|
|
if (it == m_RequestedDestinations.end ()) // not exist yet
|
|
|
|
if (it == m_RequestedDestinations.end ()) // not exist yet
|
|
|
|
{ |
|
|
|
{ |
|
|
|
RequestedDestination * d = new RequestedDestination (dest, isLeaseSet, isExploratory); |
|
|
|
RequestedDestination * d = new RequestedDestination (dest, isLeaseSet, isExploratory, pool); |
|
|
|
m_RequestedDestinations[dest] = d; |
|
|
|
m_RequestedDestinations[dest] = d; |
|
|
|
return d; |
|
|
|
return d; |
|
|
|
} |
|
|
|
} |
|
|
@ -820,13 +822,13 @@ namespace data |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NetDb::Subscribe (const IdentHash& ident) |
|
|
|
void NetDb::Subscribe (const IdentHash& ident, i2p::tunnel::TunnelPool * pool) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LeaseSet * leaseSet = FindLeaseSet (ident); |
|
|
|
LeaseSet * leaseSet = FindLeaseSet (ident); |
|
|
|
if (!leaseSet) |
|
|
|
if (!leaseSet) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("LeaseSet requested"); |
|
|
|
LogPrint ("LeaseSet requested"); |
|
|
|
RequestDestination (ident, true); |
|
|
|
RequestDestination (ident, true, pool); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
leaseSet->SetUnsolicited (false); |
|
|
|
leaseSet->SetUnsolicited (false); |
|
|
|