From 73b77c83b8ae35015647f4d5ea9c985e43998b21 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 24 Jan 2022 13:25:47 -0500 Subject: [PATCH] select compatible outbound tunnel --- libi2pd_client/I2CP.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libi2pd_client/I2CP.cpp b/libi2pd_client/I2CP.cpp index 6f25c2e8..7552c6c5 100644 --- a/libi2pd_client/I2CP.cpp +++ b/libi2pd_client/I2CP.cpp @@ -204,10 +204,16 @@ namespace client } else { - outboundTunnel = GetTunnelPool ()->GetNextOutboundTunnel (); - auto leases = remote->GetNonExpiredLeases (); + auto leases = remote->GetNonExpiredLeases (false); // without threshold + if (leases.empty ()) + leases = remote->GetNonExpiredLeases (true); // with threshold if (!leases.empty ()) + { remoteLease = leases[rand () % leases.size ()]; + auto leaseRouter = i2p::data::netdb.FindRouter (remoteLease->tunnelGateway); + outboundTunnel = GetTunnelPool ()->GetNextOutboundTunnel (nullptr, + leaseRouter ? leaseRouter->GetCompatibleTransports (false) : (i2p::data::RouterInfo::CompatibleTransports)i2p::data::RouterInfo::eAllTransports); + } if (remoteLease && outboundTunnel) remoteSession->SetSharedRoutingPath (std::make_shared ( i2p::garlic::GarlicRoutingPath{outboundTunnel, remoteLease, 10000, 0, 0})); // 10 secs RTT