From 58ebd8cc5915da9e46431081a6b652cc67699ac9 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 24 Feb 2015 11:58:39 -0500 Subject: [PATCH] 1 hours expiration of RI in case of floodfill --- NetDb.cpp | 26 ++++++++++++++++++++------ RouterContext.h | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/NetDb.cpp b/NetDb.cpp index f417809b..e2d1d3b5 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -410,16 +410,30 @@ namespace data else { // RouterInfo expires after 1 hour if uses introducer - if ((it.second->UsesIntroducer () && ts > it.second->GetTimestamp () + 3600*1000LL) // 1 hour - // RouterInfo expires in 72 hours if more than 300 - || (total > 300 && ts > it.second->GetTimestamp () + 3*24*3600*1000LL)) // 3 days - { - total--; + if (it.second->UsesIntroducer () && ts > it.second->GetTimestamp () + 3600*1000LL) // 1 hour it.second->SetUnreachable (true); - } + else if (total > 25 && ts > (i2p::context.GetStartupTime () + 600)*1000LL) // routers don't expire if less than 25 or uptime is less than 10 minutes + { + if (i2p::context.IsFloodfill ()) + { + if (ts > it.second->GetTimestamp () + 3600*1000LL) // 1 hours + it.second->SetUnreachable (true); + } + else if (total > 300) + { + if (ts > it.second->GetTimestamp () + 30*3600*1000LL) // 30 hours + it.second->SetUnreachable (true); + } + else if (total > 120) + { + if (ts > it.second->GetTimestamp () + 72*3600*1000LL) // 72 hours + it.second->SetUnreachable (true); + } + } if (it.second->IsUnreachable ()) { + total--; // delete RI file if (boost::filesystem::exists (GetFilePath (fullDirectory, it.second.get ()))) { diff --git a/RouterContext.h b/RouterContext.h index 0073d538..c2924814 100644 --- a/RouterContext.h +++ b/RouterContext.h @@ -32,6 +32,7 @@ namespace i2p } CryptoPP::RandomNumberGenerator& GetRandomNumberGenerator () { return m_Rnd; }; uint32_t GetUptime () const; + uint32_t GetStartupTime () const { return m_StartupTime; }; void UpdatePort (int port); // called from Daemon void UpdateAddress (const boost::asio::ip::address& host); // called from SSU or Daemon