mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
* Add LeaseSetBufferValidate which checks lease validity and extracts timestamp
* check for leases with LeaseSetBufferValidate before update in floodfill code as to prevent malicous nodes removing good LS
This commit is contained in:
parent
3820b51960
commit
4a77a03033
3 changed files with 46 additions and 8 deletions
|
@ -237,22 +237,20 @@ namespace data
|
|||
auto it = m_LeaseSets.find(ident);
|
||||
if (it != m_LeaseSets.end ())
|
||||
{
|
||||
if (it->second->IsNewer (buf, len))
|
||||
uint64_t expires;
|
||||
if(LeaseSetBufferValidate(buf, len, expires))
|
||||
{
|
||||
it->second->Update (buf, len);
|
||||
if (it->second->IsValid ())
|
||||
if(it->second->GetExpirationTime() < expires)
|
||||
{
|
||||
it->second->Update (buf, len);
|
||||
LogPrint (eLogInfo, "NetDb: LeaseSet updated: ", ident.ToBase32());
|
||||
updated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogPrint (eLogWarning, "NetDb: LeaseSet update failed: ", ident.ToBase32());
|
||||
m_LeaseSets.erase (it);
|
||||
}
|
||||
LogPrint(eLogDebug, "NetDb: LeaseSet is older: ", ident.ToBase32());
|
||||
}
|
||||
else
|
||||
LogPrint (eLogDebug, "NetDb: LeaseSet is older: ", ident.ToBase32());
|
||||
LogPrint(eLogError, "NetDb: LeaseSet is invalid: ", ident.ToBase32());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue