From fdf174c20536de36cd69a2b23f93baefb11f2a53 Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 7 Mar 2026 16:42:16 -0500 Subject: [PATCH] recreate zero and one hop tunnels after being offline --- libi2pd/Tunnel.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libi2pd/Tunnel.cpp b/libi2pd/Tunnel.cpp index b9e0a661..37b0abda 100644 --- a/libi2pd/Tunnel.cpp +++ b/libi2pd/Tunnel.cpp @@ -877,6 +877,7 @@ namespace tunnel void Tunnels::ManageOutboundTunnels (uint64_t ts, std::vector >& toRecreate) { + size_t numEstablishedOutboundTunnels = 0; for (auto it = m_OutboundTunnels.begin (); it != m_OutboundTunnels.end ();) { auto tunnel = *it; @@ -903,12 +904,13 @@ namespace tunnel } if (ts + TUNNEL_EXPIRATION_THRESHOLD > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) tunnel->SetState (eTunnelStateExpiring); + numEstablishedOutboundTunnels++; } ++it; } } - if (m_OutboundTunnels.size () < 3) + if (numEstablishedOutboundTunnels < 3) { // trying to create one more outbound tunnel auto inboundTunnel = GetNextInboundTunnel (); @@ -926,6 +928,7 @@ namespace tunnel void Tunnels::ManageInboundTunnels (uint64_t ts, std::vector >& toRecreate) { + size_t numEstablishedInboundTunnels = 0; for (auto it = m_InboundTunnels.begin (); it != m_InboundTunnels.end ();) { auto tunnel = *it; @@ -955,12 +958,13 @@ namespace tunnel tunnel->SetState (eTunnelStateExpiring); else // we don't need to cleanup expiring tunnels tunnel->Cleanup (); + numEstablishedInboundTunnels++; } it++; } } - if (m_InboundTunnels.empty ()) + if (!numEstablishedInboundTunnels) { LogPrint (eLogDebug, "Tunnel: Creating zero hops inbound tunnel"); CreateZeroHopsInboundTunnel (nullptr); @@ -977,7 +981,7 @@ namespace tunnel return; } - if (m_OutboundTunnels.empty () || m_InboundTunnels.size () < 3) + if (m_OutboundTunnels.empty () || numEstablishedInboundTunnels < 3) { // trying to create one more inbound tunnel auto router = i2p::transport::transports.RoutesRestricted() ?