From ccf689ffd5038b47c0753201f8cb1f0692c92d82 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 26 Feb 2015 21:05:35 -0500 Subject: [PATCH] connect to introducer if not any yet --- NetDb.cpp | 9 +++++++++ NetDb.h | 1 + SSU.cpp | 7 +++++++ 3 files changed, 17 insertions(+) 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 (); } }