Skip to content

Commit

Permalink
don't accept too old RouterInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Apr 29, 2024
1 parent 8c6c954 commit a1fcd8a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libi2pd/NetDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,14 @@ namespace data
else
{
r = std::make_shared<RouterInfo> (buf, len);
if (!r->IsUnreachable () && r->HasValidAddresses () && (!r->IsFloodfill () || !r->GetProfile ()->IsUnreachable ()) &&
i2p::util::GetMillisecondsSinceEpoch () + NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL > r->GetTimestamp ())
bool isValid = !r->IsUnreachable () && r->HasValidAddresses () && (!r->IsFloodfill () || !r->GetProfile ()->IsUnreachable ());
if (isValid)
{
auto mts = i2p::util::GetMillisecondsSinceEpoch ();
isValid = mts + NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL > r->GetTimestamp () && // from future
mts < r->GetTimestamp () + NETDB_MAX_EXPIRATION_TIMEOUT*1000LL; // too old
}
if (isValid)
{
bool inserted = false;
{
Expand Down

0 comments on commit a1fcd8a

Please sign in to comment.