mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-13 19:37:51 +00:00
specify number of hops for inbound tunnels
This commit is contained in:
parent
ad65e52ce0
commit
6ce3e41a70
@ -167,17 +167,28 @@ namespace tunnel
|
|||||||
OutboundTunnel * outboundTunnel = m_OutboundTunnels.size () > 0 ?
|
OutboundTunnel * outboundTunnel = m_OutboundTunnels.size () > 0 ?
|
||||||
*m_OutboundTunnels.begin () : tunnels.GetNextOutboundTunnel ();
|
*m_OutboundTunnels.begin () : tunnels.GetNextOutboundTunnel ();
|
||||||
LogPrint ("Creating destination inbound tunnel...");
|
LogPrint ("Creating destination inbound tunnel...");
|
||||||
auto firstHop = i2p::data::netdb.GetRandomRouter (outboundTunnel ? outboundTunnel->GetEndpointRouter () : nullptr);
|
const i2p::data::RouterInfo * prevHop = &i2p::context.GetRouterInfo ();
|
||||||
auto secondHop = outboundTunnel ? outboundTunnel->GetTunnelConfig ()->GetFirstHop ()->router : nullptr;
|
std::vector<const i2p::data::RouterInfo *> hops;
|
||||||
if (!secondHop || secondHop->GetIdentHash () == i2p::context.GetIdentHash ())
|
int numHops = m_NumHops;
|
||||||
secondHop = i2p::data::netdb.GetRandomRouter (firstHop);
|
if (outboundTunnel)
|
||||||
auto * tunnel = tunnels.CreateTunnel<InboundTunnel> (
|
{
|
||||||
new TunnelConfig (std::vector<const i2p::data::RouterInfo *>
|
// last hop
|
||||||
{
|
auto hop = outboundTunnel->GetTunnelConfig ()->GetFirstHop ()->router;
|
||||||
firstHop,
|
if (hop->GetIdentHash () != i2p::context.GetIdentHash ()) // outbound shouldn't be zero-hop tunnel
|
||||||
secondHop
|
{
|
||||||
}),
|
prevHop = hop;
|
||||||
outboundTunnel);
|
hops.push_back (prevHop);
|
||||||
|
numHops--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < numHops; i++)
|
||||||
|
{
|
||||||
|
auto hop = i2p::data::netdb.GetRandomRouter (prevHop);
|
||||||
|
prevHop = hop;
|
||||||
|
hops.push_back (hop);
|
||||||
|
}
|
||||||
|
std::reverse (hops.begin (), hops.end ());
|
||||||
|
auto * tunnel = tunnels.CreateTunnel<InboundTunnel> (new TunnelConfig (hops));
|
||||||
tunnel->SetTunnelPool (this);
|
tunnel->SetTunnelPool (this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user