|
|
@ -384,14 +384,11 @@ namespace tunnel |
|
|
|
it++; |
|
|
|
it++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_OutboundTunnels.size () < 15) // TODO: store exploratory tunnels explicitly
|
|
|
|
if (m_OutboundTunnels.size () < 5) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// trying to create one more oubound tunnel
|
|
|
|
// trying to create one more oubound tunnel
|
|
|
|
if (m_InboundTunnels.empty ()) return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
InboundTunnel * inboundTunnel = GetNextInboundTunnel (); |
|
|
|
InboundTunnel * inboundTunnel = GetNextInboundTunnel (); |
|
|
|
if (m_OutboundTunnels.empty () || m_OutboundTunnels.size () < 3) |
|
|
|
if (!inboundTunnel) return; |
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint ("Creating one hop outbound tunnel..."); |
|
|
|
LogPrint ("Creating one hop outbound tunnel..."); |
|
|
|
CreateTunnel<OutboundTunnel> ( |
|
|
|
CreateTunnel<OutboundTunnel> ( |
|
|
|
new TunnelConfig (std::vector<const i2p::data::RouterInfo *> |
|
|
|
new TunnelConfig (std::vector<const i2p::data::RouterInfo *> |
|
|
@ -400,20 +397,6 @@ namespace tunnel |
|
|
|
}, |
|
|
|
}, |
|
|
|
inboundTunnel->GetTunnelConfig ())); |
|
|
|
inboundTunnel->GetTunnelConfig ())); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LogPrint ("Creating two hops outbound tunnel..."); |
|
|
|
|
|
|
|
auto firstHop = i2p::data::netdb.GetRandomRouter (); |
|
|
|
|
|
|
|
CreateTunnel<OutboundTunnel> ( |
|
|
|
|
|
|
|
new TunnelConfig (std::vector<const i2p::data::RouterInfo *> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
firstHop, |
|
|
|
|
|
|
|
i2p::data::netdb.GetRandomRouter (firstHop) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
inboundTunnel->GetTunnelConfig ())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Tunnels::ManageInboundTunnels () |
|
|
|
void Tunnels::ManageInboundTunnels () |
|
|
@ -437,14 +420,14 @@ namespace tunnel |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Creating zero hops inbound tunnel..."); |
|
|
|
LogPrint ("Creating zero hops inbound tunnel..."); |
|
|
|
CreateZeroHopsInboundTunnel (); |
|
|
|
CreateZeroHopsInboundTunnel (); |
|
|
|
|
|
|
|
if (!m_ExploratoryPool) |
|
|
|
|
|
|
|
m_ExploratoryPool = CreateTunnelPool (i2p::context); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (m_InboundTunnels.size () < 15) // TODO: store exploratory tunnels explicitly
|
|
|
|
if (m_OutboundTunnels.empty () || m_InboundTunnels.size () < 5) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// trying to create one more inbound tunnel
|
|
|
|
// trying to create one more inbound tunnel
|
|
|
|
if (m_OutboundTunnels.empty () || m_InboundTunnels.size () < 3) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint ("Creating one hop inbound tunnel..."); |
|
|
|
LogPrint ("Creating one hop inbound tunnel..."); |
|
|
|
CreateTunnel<InboundTunnel> ( |
|
|
|
CreateTunnel<InboundTunnel> ( |
|
|
|
new TunnelConfig (std::vector<const i2p::data::RouterInfo *> |
|
|
|
new TunnelConfig (std::vector<const i2p::data::RouterInfo *> |
|
|
@ -452,21 +435,6 @@ namespace tunnel |
|
|
|
i2p::data::netdb.GetRandomRouter () |
|
|
|
i2p::data::netdb.GetRandomRouter () |
|
|
|
})); |
|
|
|
})); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
OutboundTunnel * outboundTunnel = GetNextOutboundTunnel (); |
|
|
|
|
|
|
|
LogPrint ("Creating two hops inbound tunnel..."); |
|
|
|
|
|
|
|
auto router = outboundTunnel->GetTunnelConfig ()->GetFirstHop ()->router; |
|
|
|
|
|
|
|
auto firstHop = i2p::data::netdb.GetRandomRouter (outboundTunnel->GetEndpointRouter ()); |
|
|
|
|
|
|
|
CreateTunnel<InboundTunnel> ( |
|
|
|
|
|
|
|
new TunnelConfig (std::vector<const i2p::data::RouterInfo *> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
firstHop, |
|
|
|
|
|
|
|
router != &i2p::context.GetRouterInfo () ? router : i2p::data::netdb.GetRandomRouter (firstHop) |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
outboundTunnel); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Tunnels::ManageTransitTunnels () |
|
|
|
void Tunnels::ManageTransitTunnels () |
|
|
|