From def9873a7093f5103d1f19fc5332d37531f8b605 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 2 Mar 2021 21:10:19 -0500 Subject: [PATCH] request multiple introducers at the time --- libi2pd/NetDb.cpp | 2 +- libi2pd/SSU.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libi2pd/NetDb.cpp b/libi2pd/NetDb.cpp index 7f71619e..f6632d2a 100644 --- a/libi2pd/NetDb.cpp +++ b/libi2pd/NetDb.cpp @@ -1169,7 +1169,7 @@ namespace data return GetRandomRouter ( [](std::shared_ptr router)->bool { - return !router->IsHidden () && router->IsIntroducer (); + return router->IsIntroducer () && !router->IsHidden () && !router->IsFloodfill (); // floodfills don't send relay tag }); } diff --git a/libi2pd/SSU.cpp b/libi2pd/SSU.cpp index be5ac9c7..f1de3893 100644 --- a/libi2pd/SSU.cpp +++ b/libi2pd/SSU.cpp @@ -671,7 +671,7 @@ namespace transport ScheduleIntroducersUpdateTimer (); return; } - if (i2p::context.GetStatus () == eRouterStatusOK) return; // we don't need introducers anymore + if (i2p::context.GetStatus () != eRouterStatusFirewalled) return; // we don't need introducers // we are firewalled if (!i2p::context.IsUnreachable ()) i2p::context.SetUnreachable (); std::list newList; @@ -712,9 +712,19 @@ namespace transport m_Introducers = newList; if (m_Introducers.size () < SSU_MAX_NUM_INTRODUCERS) { - auto introducer = i2p::data::netdb.GetRandomIntroducer (); - if (introducer) - CreateSession (introducer); + for (auto i = m_Introducers.size (); i < SSU_MAX_NUM_INTRODUCERS; i++) + { + auto introducer = i2p::data::netdb.GetRandomIntroducer (); + if (introducer) + { + auto address = introducer->GetSSUAddress (true); // v4 + if (address && !address->host.is_unspecified ()) + { + boost::asio::ip::udp::endpoint ep (address->host, address->port); + CreateDirectSession (introducer, ep, false); + } + } + } } ScheduleIntroducersUpdateTimer (); }