From d4ec15361fc353d20892b997c318cfd80c04aa61 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 11 Dec 2025 15:23:39 -0500 Subject: [PATCH] 1 sec more to mark a tunnel slow if proxy --- libi2pd/Transports.cpp | 5 +++++ libi2pd/Transports.h | 4 +++- libi2pd/Tunnel.cpp | 6 ++++++ libi2pd/Tunnel.h | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libi2pd/Transports.cpp b/libi2pd/Transports.cpp index ebc75a60..aebbb4e4 100644 --- a/libi2pd/Transports.cpp +++ b/libi2pd/Transports.cpp @@ -1284,6 +1284,11 @@ namespace transport } } + int Transports::GetLocalDelay () const + { + return (i2p::context.GetStatus () == eRouterStatusProxy) ? 1000 : 0; // 1 sec for proxy. TODO: implement param + } + bool Transports::IsInReservedRange (const boost::asio::ip::address& host) const { return IsCheckReserved () && i2p::util::net::IsInReservedRange (host); diff --git a/libi2pd/Transports.h b/libi2pd/Transports.h index fcd2cfc6..04b916b2 100644 --- a/libi2pd/Transports.h +++ b/libi2pd/Transports.h @@ -142,7 +142,9 @@ namespace transport bool IsOnline() const { return m_IsOnline; }; void SetOnline (bool online); - + + int GetLocalDelay () const; // in millseconds + auto& GetService () { return *m_Service; }; std::shared_ptr GetNextX25519KeysPair (); void ReuseX25519KeysPair (std::shared_ptr pair); diff --git a/libi2pd/Tunnel.cpp b/libi2pd/Tunnel.cpp index a0ef2272..a3c53fc1 100644 --- a/libi2pd/Tunnel.cpp +++ b/libi2pd/Tunnel.cpp @@ -263,6 +263,12 @@ namespace tunnel m_State = state; } + bool Tunnel::IsSlow () const + { + return LatencyIsKnown() && m_Latency > HIGH_LATENCY_PER_HOP*GetNumHops () + + i2p::transport::transports.GetLocalDelay ()*1000; + } + void Tunnel::VisitTunnelHops(TunnelHopVisitor v) { // hops are in inverted order, we must return in direct order diff --git a/libi2pd/Tunnel.h b/libi2pd/Tunnel.h index cc0a9bc7..3204c059 100644 --- a/libi2pd/Tunnel.h +++ b/libi2pd/Tunnel.h @@ -118,7 +118,7 @@ namespace tunnel bool LatencyFitsRange(int lowerbound, int upperbound) const; bool LatencyIsKnown() const { return m_Latency != UNKNOWN_LATENCY; } - bool IsSlow () const { return LatencyIsKnown() && m_Latency > HIGH_LATENCY_PER_HOP*GetNumHops (); } + bool IsSlow () const; /** visit all hops we currently store */ void VisitTunnelHops(TunnelHopVisitor v);