From 1292ec67c013355d8fc0508e947f088ebc9aad2e Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 2 Mar 2024 18:02:55 -0500 Subject: [PATCH] check if remote router supports peer test --- libi2pd/SSU2.cpp | 7 +++++-- libi2pd/SSU2Session.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libi2pd/SSU2.cpp b/libi2pd/SSU2.cpp index ab152e8f..976bffbf 100644 --- a/libi2pd/SSU2.cpp +++ b/libi2pd/SSU2.cpp @@ -856,8 +856,11 @@ namespace transport auto it = m_SessionsByRouterHash.find (router->GetIdentHash ()); if (it != m_SessionsByRouterHash.end ()) { - auto s = it->second; - if (it->second->IsEstablished ()) + auto remoteAddr = it->second->GetAddress (); + if (!remoteAddr || !remoteAddr->IsPeerTesting () || + (v4 && !addr->IsV4 ()) || (!v4 && !addr->IsV6 ())) return false; + auto s = it->second; + if (s->IsEstablished ()) GetService ().post ([s]() { s->SendPeerTest (); }); else s->SetOnEstablished ([s]() { s->SendPeerTest (); }); diff --git a/libi2pd/SSU2Session.cpp b/libi2pd/SSU2Session.cpp index d5f1a40f..2c499753 100644 --- a/libi2pd/SSU2Session.cpp +++ b/libi2pd/SSU2Session.cpp @@ -2287,7 +2287,7 @@ namespace transport if (GetTestingState ()) { SetTestingState (false); - if (GetRouterStatus () != eRouterStatusFirewalled) + if (GetRouterStatus () != eRouterStatusFirewalled && addr->IsPeerTesting ()) { SetRouterStatus (eRouterStatusFirewalled); if (m_Address->IsV4 ())