mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-20 10:29:57 +00:00
check log level before calculating base32 or base64 of ident
This commit is contained in:
parent
7dd9a7a0af
commit
592d6ae4f4
@ -262,10 +262,12 @@ namespace data
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
|
if (CheckLogLevel (eLogInfo))
|
||||||
|
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
|
||||||
if (wasFloodfill != r->IsFloodfill ()) // if floodfill status updated
|
if (wasFloodfill != r->IsFloodfill ()) // if floodfill status updated
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: RouterInfo floodfill status updated: ", ident.ToBase64());
|
if (CheckLogLevel (eLogDebug))
|
||||||
|
LogPrint (eLogDebug, "NetDb: RouterInfo floodfill status updated: ", ident.ToBase64());
|
||||||
std::lock_guard<std::mutex> l(m_FloodfillsMutex);
|
std::lock_guard<std::mutex> l(m_FloodfillsMutex);
|
||||||
if (wasFloodfill)
|
if (wasFloodfill)
|
||||||
m_Floodfills.Remove (r->GetIdentHash ());
|
m_Floodfills.Remove (r->GetIdentHash ());
|
||||||
@ -280,7 +282,8 @@ namespace data
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: RouterInfo is older: ", ident.ToBase64());
|
if (CheckLogLevel (eLogDebug))
|
||||||
|
LogPrint (eLogDebug, "NetDb: RouterInfo is older: ", ident.ToBase64());
|
||||||
updated = false;
|
updated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,7 +300,8 @@ namespace data
|
|||||||
}
|
}
|
||||||
if (inserted)
|
if (inserted)
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase64());
|
if (CheckLogLevel (eLogInfo))
|
||||||
|
LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase64());
|
||||||
if (r->IsFloodfill () && r->IsEligibleFloodfill ())
|
if (r->IsFloodfill () && r->IsEligibleFloodfill ())
|
||||||
{
|
{
|
||||||
if (m_Floodfills.GetSize () < NETDB_NUM_FLOODFILLS_THRESHOLD ||
|
if (m_Floodfills.GetSize () < NETDB_NUM_FLOODFILLS_THRESHOLD ||
|
||||||
@ -338,10 +342,11 @@ namespace data
|
|||||||
if(it->second->GetExpirationTime() < expires)
|
if(it->second->GetExpirationTime() < expires)
|
||||||
{
|
{
|
||||||
it->second->Update (buf, len, false); // signature is verified already
|
it->second->Update (buf, len, false); // signature is verified already
|
||||||
LogPrint (eLogInfo, "NetDb: LeaseSet updated: ", ident.ToBase32());
|
if (CheckLogLevel (eLogInfo))
|
||||||
|
LogPrint (eLogInfo, "NetDb: LeaseSet updated: ", ident.ToBase32());
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
else
|
else if (CheckLogLevel (eLogDebug))
|
||||||
LogPrint(eLogDebug, "NetDb: LeaseSet is older: ", ident.ToBase32());
|
LogPrint(eLogDebug, "NetDb: LeaseSet is older: ", ident.ToBase32());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -352,7 +357,8 @@ namespace data
|
|||||||
auto leaseSet = std::make_shared<LeaseSet> (buf, len, false); // we don't need leases in netdb
|
auto leaseSet = std::make_shared<LeaseSet> (buf, len, false); // we don't need leases in netdb
|
||||||
if (leaseSet->IsValid ())
|
if (leaseSet->IsValid ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "NetDb: LeaseSet added: ", ident.ToBase32());
|
if (CheckLogLevel (eLogInfo))
|
||||||
|
LogPrint (eLogInfo, "NetDb: LeaseSet added: ", ident.ToBase32());
|
||||||
m_LeaseSets[ident] = leaseSet;
|
m_LeaseSets[ident] = leaseSet;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
@ -376,7 +382,8 @@ namespace data
|
|||||||
i2p::util::GetSecondsSinceEpoch () + NETDB_EXPIRATION_TIMEOUT_THRESHOLD > leaseSet->GetPublishedTimestamp ())
|
i2p::util::GetSecondsSinceEpoch () + NETDB_EXPIRATION_TIMEOUT_THRESHOLD > leaseSet->GetPublishedTimestamp ())
|
||||||
{
|
{
|
||||||
// TODO: implement actual update
|
// TODO: implement actual update
|
||||||
LogPrint (eLogInfo, "NetDb: LeaseSet2 updated: ", ident.ToBase32());
|
if (CheckLogLevel (eLogInfo))
|
||||||
|
LogPrint (eLogInfo, "NetDb: LeaseSet2 updated: ", ident.ToBase32());
|
||||||
m_LeaseSets[ident] = leaseSet;
|
m_LeaseSets[ident] = leaseSet;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -863,19 +870,22 @@ namespace data
|
|||||||
{
|
{
|
||||||
if (storeType == NETDB_STORE_TYPE_LEASESET) // 1
|
if (storeType == NETDB_STORE_TYPE_LEASESET) // 1
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet for ", ident.ToBase32());
|
if (CheckLogLevel (eLogDebug))
|
||||||
|
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet for ", ident.ToBase32());
|
||||||
updated = AddLeaseSet (ident, buf + offset, len - offset);
|
updated = AddLeaseSet (ident, buf + offset, len - offset);
|
||||||
}
|
}
|
||||||
else // all others are considered as LeaseSet2
|
else // all others are considered as LeaseSet2
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet2 of type ", int(storeType), " for ", ident.ToBase32());
|
if (CheckLogLevel (eLogDebug))
|
||||||
|
LogPrint (eLogDebug, "NetDb: Store request: LeaseSet2 of type ", int(storeType), " for ", ident.ToBase32());
|
||||||
updated = AddLeaseSet2 (ident, buf + offset, len - offset, storeType);
|
updated = AddLeaseSet2 (ident, buf + offset, len - offset, storeType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // RouterInfo
|
else // RouterInfo
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "NetDb: Store request: RouterInfo ", ident.ToBase64());
|
if (CheckLogLevel (eLogDebug))
|
||||||
|
LogPrint (eLogDebug, "NetDb: Store request: RouterInfo ", ident.ToBase64());
|
||||||
size_t size = bufbe16toh (buf + offset);
|
size_t size = bufbe16toh (buf + offset);
|
||||||
offset += 2;
|
offset += 2;
|
||||||
if (size > MAX_RI_BUFFER_SIZE || size > len - offset)
|
if (size > MAX_RI_BUFFER_SIZE || size > len - offset)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user