diff --git a/NetDb.cpp b/NetDb.cpp index 21660eb6..1bb3b822 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -894,6 +894,15 @@ namespace data }); } + std::shared_ptr NetDb::GetRandomIntroducer () const + { + return GetRandomRouter ( + [](std::shared_ptr router)->bool + { + return !router->IsHidden () && router->IsIntroducer (); + }); + } + std::shared_ptr NetDb::GetHighBandwidthRandomRouter (std::shared_ptr compatibleWith) const { return GetRandomRouter ( diff --git a/NetDb.h b/NetDb.h index 6a0211d5..7b515e2a 100644 --- a/NetDb.h +++ b/NetDb.h @@ -81,6 +81,7 @@ namespace data std::shared_ptr GetRandomRouter (std::shared_ptr compatibleWith) const; std::shared_ptr GetHighBandwidthRandomRouter (std::shared_ptr compatibleWith) const; std::shared_ptr GetRandomPeerTestRouter () const; + std::shared_ptr GetRandomIntroducer () const; std::shared_ptr GetClosestFloodfill (const IdentHash& destination, const std::set& excluded) const; std::shared_ptr GetClosestNonFloodfill (const IdentHash& destination, const std::set& excluded) const; void SetUnreachable (const IdentHash& ident, bool unreachable); diff --git a/SSU.cpp b/SSU.cpp index be5902b1..7b5a22ff 100644 --- a/SSU.cpp +++ b/SSU.cpp @@ -3,6 +3,7 @@ #include "Log.h" #include "Timestamp.h" #include "RouterContext.h" +#include "NetDb.h" #include "SSU.h" namespace i2p @@ -460,6 +461,12 @@ namespace transport } } m_Introducers = newList; + if (m_Introducers.empty ()) + { + auto introducer = i2p::data::netdb.GetRandomIntroducer (); + if (introducer) + GetSession (introducer); + } ScheduleIntroducersUpdateTimer (); } }