mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
delete invalid router after update
This commit is contained in:
parent
7bde4de1f5
commit
d15581d95e
@ -276,7 +276,22 @@ namespace data
|
|||||||
bool wasFloodfill = r->IsFloodfill ();
|
bool wasFloodfill = r->IsFloodfill ();
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||||
r->Update (buf, len);
|
if (!r->Update (buf, len))
|
||||||
|
{
|
||||||
|
updated = false;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
if (r->IsUnreachable ())
|
||||||
|
{
|
||||||
|
// delete router as invalid after update
|
||||||
|
m_RouterInfos.erase (ident);
|
||||||
|
if (wasFloodfill)
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||||
|
m_Floodfills.remove (r);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
|
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
|
||||||
if (wasFloodfill != r->IsFloodfill ()) // if floodfill status updated
|
if (wasFloodfill != r->IsFloodfill ()) // if floodfill status updated
|
||||||
|
@ -79,13 +79,12 @@ namespace data
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterInfo::Update (const uint8_t * buf, size_t len)
|
bool RouterInfo::Update (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
if (len > MAX_RI_BUFFER_SIZE)
|
if (len > MAX_RI_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "RouterInfo: Buffer is too long ", len);
|
LogPrint (eLogWarning, "RouterInfo: Updated buffer is too long ", len, ". Not changed");
|
||||||
m_IsUnreachable = true;
|
return false;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// verify signature since we have identity already
|
// verify signature since we have identity already
|
||||||
int l = len - m_RouterIdentity->GetSignatureLen ();
|
int l = len - m_RouterIdentity->GetSignatureLen ();
|
||||||
@ -110,9 +109,10 @@ namespace data
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "RouterInfo: Signature verification failed");
|
LogPrint (eLogWarning, "RouterInfo: Updated signature verification failed. Not changed");
|
||||||
m_IsUnreachable = true;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterInfo::SetRouterIdentity (std::shared_ptr<const IdentityEx> identity)
|
void RouterInfo::SetRouterIdentity (std::shared_ptr<const IdentityEx> identity)
|
||||||
|
@ -253,7 +253,7 @@ namespace data
|
|||||||
std::shared_ptr<RouterProfile> GetProfile () const;
|
std::shared_ptr<RouterProfile> GetProfile () const;
|
||||||
void DropProfile () { m_Profile = nullptr; };
|
void DropProfile () { m_Profile = nullptr; };
|
||||||
|
|
||||||
void Update (const uint8_t * buf, size_t len);
|
bool Update (const uint8_t * buf, size_t len);
|
||||||
void DeleteBuffer () { m_Buffer = nullptr; };
|
void DeleteBuffer () { m_Buffer = nullptr; };
|
||||||
bool IsNewer (const uint8_t * buf, size_t len) const;
|
bool IsNewer (const uint8_t * buf, size_t len) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user