Browse Source

delete routers with timestmep from future

pull/1828/head
orignal 2 years ago
parent
commit
5ac01ddce8
  1. 8
      libi2pd/NetDb.cpp
  2. 1
      libi2pd/NetDb.hpp

8
libi2pd/NetDb.cpp

@ -494,7 +494,8 @@ namespace data @@ -494,7 +494,8 @@ namespace data
{
auto r = std::make_shared<RouterInfo>(path);
if (r->GetRouterIdentity () && !r->IsUnreachable () && r->HasValidAddresses () &&
ts < r->GetTimestamp () + 24*60*60*NETDB_MAX_OFFLINE_EXPIRATION_TIMEOUT*1000LL)
ts < r->GetTimestamp () + 24*60*60*NETDB_MAX_OFFLINE_EXPIRATION_TIMEOUT*1000LL && // too old
ts + NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL > r->GetTimestamp ()) // from future
{
r->DeleteBuffer ();
if (m_RouterInfos.emplace (r->GetIdentHash (), r).second)
@ -638,6 +639,11 @@ namespace data @@ -638,6 +639,11 @@ namespace data
}
else if (checkForExpiration && ts > it.second->GetTimestamp () + expirationTimeout)
it.second->SetUnreachable (true);
else if (ts + NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL < it.second->GetTimestamp ())
{
LogPrint (eLogWarning, "NetDb: RouterInfo is from future for ", (it.second->GetTimestamp () - ts)/1000LL, " seconds");
it.second->SetUnreachable (true);
}
if (it.second->IsUnreachable ())
{

1
libi2pd/NetDb.hpp

@ -44,6 +44,7 @@ namespace data @@ -44,6 +44,7 @@ namespace data
const int NETDB_MIN_EXPIRATION_TIMEOUT = 90 * 60; // 1.5 hours
const int NETDB_MAX_EXPIRATION_TIMEOUT = 27 * 60 * 60; // 27 hours
const int NETDB_MAX_OFFLINE_EXPIRATION_TIMEOUT = 180; // in days
const int NETDB_EXPIRATION_TIMEOUT_THRESHOLD = 2*60; // 2 minutes
const int NETDB_PUBLISH_INTERVAL = 60 * 40;
const int NETDB_PUBLISH_CONFIRMATION_TIMEOUT = 5; // in seconds
const int NETDB_MAX_PUBLISH_EXCLUDED_FLOODFILLS = 15;

Loading…
Cancel
Save