mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
select existing connection for first hop of a tunnel
This commit is contained in:
parent
b64b5d9103
commit
66dafca61a
@ -330,8 +330,8 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
if (m_ExplicitPeers) return SelectExplicitPeers (peers, isInbound);
|
if (m_ExplicitPeers) return SelectExplicitPeers (peers, isInbound);
|
||||||
int numHops = isInbound ? m_NumInboundHops : m_NumOutboundHops;
|
int numHops = isInbound ? m_NumInboundHops : m_NumOutboundHops;
|
||||||
if (numHops <= 0) return true;
|
if (numHops <= 0) return true; // peers is empty
|
||||||
auto prevHop = i2p::context.GetSharedRouterInfo();
|
auto prevHop = i2p::context.GetSharedRouterInfo ();
|
||||||
if(i2p::transport::transports.RoutesRestricted())
|
if(i2p::transport::transports.RoutesRestricted())
|
||||||
{
|
{
|
||||||
/** if routes are restricted prepend trusted first hop */
|
/** if routes are restricted prepend trusted first hop */
|
||||||
@ -340,6 +340,17 @@ namespace tunnel
|
|||||||
peers.push_back(hop->GetRouterIdentity());
|
peers.push_back(hop->GetRouterIdentity());
|
||||||
prevHop = hop;
|
prevHop = hop;
|
||||||
}
|
}
|
||||||
|
else if (i2p::transport::transports.GetNumPeers () > 25)
|
||||||
|
{
|
||||||
|
auto r = i2p::transport::transports.GetRandomPeer ();
|
||||||
|
if (r && !r->GetProfile ()->IsBad ())
|
||||||
|
{
|
||||||
|
prevHop = r;
|
||||||
|
peers.push_back (r->GetRouterIdentity ());
|
||||||
|
numHops--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i = 0; i < numHops; i++ )
|
for(int i = 0; i < numHops; i++ )
|
||||||
{
|
{
|
||||||
auto hop = SelectNextHop (prevHop);
|
auto hop = SelectNextHop (prevHop);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user