From 32ab95478e8f692428fcb037f95a54050dc5634f Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 18 Aug 2024 18:34:28 -0400 Subject: [PATCH] check crypto type and congestion of connected peer for tunnel --- libi2pd/Transports.cpp | 2 +- libi2pd/Transports.h | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index 9a10ca72..4818d57f 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -1055,7 +1055,7 @@ namespace transport [isHighBandwidth](std::shared_ptr peer)->bool { // connected, not overloaded and not slow - return !peer->router && peer->IsConnected () && peer->isReachable && + return !peer->router && peer->IsConnected () && peer->isEligible && peer->sessions.front ()->GetSendQueueSize () <= PEER_ROUTER_INFO_OVERLOAD_QUEUE_SIZE && !peer->sessions.front ()->IsSlow () && !peer->sessions.front ()->IsBandwidthExceeded (peer->isHighBandwidth) && (!isHighBandwidth || peer->isHighBandwidth); diff --git a/libi2pd/Transports.h b/libi2pd/Transports.h index 0ad0c616..12846aa5 100644 --- a/libi2pd/Transports.h +++ b/libi2pd/Transports.h @@ -72,17 +72,18 @@ namespace transport uint64_t creationTime, nextRouterInfoUpdateTime; std::vector > delayedMessages; std::vector priority; - bool isHighBandwidth, isReachable; + bool isHighBandwidth, isEligible; Peer (std::shared_ptr r, uint64_t ts): numAttempts (0), router (r), creationTime (ts), nextRouterInfoUpdateTime (ts + PEER_ROUTER_INFO_UPDATE_INTERVAL), - isHighBandwidth (false), isReachable (false) + isHighBandwidth (false), isEligible (false) { if (router) { isHighBandwidth = router->IsHighBandwidth (); - isReachable = (bool)router->GetCompatibleTransports (true); + isEligible = router->IsECIES () && (bool)router->GetCompatibleTransports (true) && // reachable + router->GetCongestion () != i2p::data::RouterInfo::eRejectAll; } } @@ -101,7 +102,8 @@ namespace transport if (router) { isHighBandwidth = router->IsHighBandwidth (); - isReachable = (bool)router->GetCompatibleTransports (true); + isEligible = router->IsECIES () && (bool)router->GetCompatibleTransports (true) && // reachable + router->GetCongestion () != i2p::data::RouterInfo::eRejectAll; } }