1
0
mirror of https://github.com/PurpleI2P/i2pd.git synced 2025-01-22 08:14:15 +00:00

try to select reachable router of inbound tunnel gateway

This commit is contained in:
orignal 2021-01-28 13:33:12 -05:00
parent 7c8280934a
commit 484f69f16b

View File

@ -414,7 +414,8 @@ namespace tunnel
else if (i2p::transport::transports.GetNumPeers () > 25)
{
auto r = i2p::transport::transports.GetRandomPeer ();
if (r && !r->GetProfile ()->IsBad ())
if (r && !r->GetProfile ()->IsBad () &&
(numHops > 1 || !inbound || r->IsReachable ())) // first must be reachable
{
prevHop = r;
peers.push_back (r->GetRouterIdentity ());
@ -430,6 +431,12 @@ namespace tunnel
LogPrint (eLogError, "Tunnels: Can't select next hop for ", prevHop->GetIdentHashBase64 ());
return false;
}
if (inbound && (i == numHops - 1) && !hop->IsReachable ())
{
// if first is not reachable try again
auto hop1 = nextHop (prevHop);
if (hop1) hop = hop1;
}
prevHop = hop;
peers.push_back (hop->GetRouterIdentity ());
}