mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
don't load router profile in NTCP2 or SSU2 thread when check for duplicates
This commit is contained in:
parent
57986bd348
commit
39e07ac265
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, The PurpleI2P Project
|
||||||
*
|
*
|
||||||
* This file is part of Purple i2pd project and licensed under BSD3
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
|
@ -819,17 +819,22 @@ namespace transport
|
||||||
Terminate ();
|
Terminate ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::shared_ptr<i2p::data::RouterProfile> profile; // not null if older
|
|
||||||
|
bool isOlder = false;
|
||||||
if (ri.GetTimestamp () + i2p::data::NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL < ri1->GetTimestamp ())
|
if (ri.GetTimestamp () + i2p::data::NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL < ri1->GetTimestamp ())
|
||||||
{
|
{
|
||||||
// received RouterInfo is older than one in netdb
|
// received RouterInfo is older than one in netdb
|
||||||
profile = i2p::data::GetRouterProfile (ri1->GetIdentHash ()); // retrieve profile
|
isOlder = true;
|
||||||
|
if (ri1->HasProfile ())
|
||||||
|
{
|
||||||
|
auto profile = i2p::data::GetRouterProfile (ri1->GetIdentHash ()); // retrieve profile
|
||||||
if (profile && profile->IsDuplicated ())
|
if (profile && profile->IsDuplicated ())
|
||||||
{
|
{
|
||||||
SendTerminationAndTerminate (eNTCP2Banned);
|
SendTerminationAndTerminate (eNTCP2Banned);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto addr = m_RemoteEndpoint.address ().is_v4 () ? ri1->GetNTCP2V4Address () :
|
auto addr = m_RemoteEndpoint.address ().is_v4 () ? ri1->GetNTCP2V4Address () :
|
||||||
(i2p::util::net::IsYggdrasilAddress (m_RemoteEndpoint.address ()) ? ri1->GetYggdrasilAddress () : ri1->GetNTCP2V6Address ());
|
(i2p::util::net::IsYggdrasilAddress (m_RemoteEndpoint.address ()) ? ri1->GetYggdrasilAddress () : ri1->GetNTCP2V6Address ());
|
||||||
|
@ -844,8 +849,12 @@ namespace transport
|
||||||
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data () + 1, addr->host.to_v6 ().to_bytes ().data () + 1, 7) : // from the same yggdrasil subnet
|
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data () + 1, addr->host.to_v6 ().to_bytes ().data () + 1, 7) : // from the same yggdrasil subnet
|
||||||
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data (), addr->host.to_v6 ().to_bytes ().data (), 8)))) // temporary address
|
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data (), addr->host.to_v6 ().to_bytes ().data (), 8)))) // temporary address
|
||||||
{
|
{
|
||||||
if (profile) // older router?
|
if (isOlder) // older router?
|
||||||
profile->Duplicated (); // mark router as duplicated in profile
|
i2p::data::UpdateRouterProfile (ri1->GetIdentHash (),
|
||||||
|
[](std::shared_ptr<i2p::data::RouterProfile> profile)
|
||||||
|
{
|
||||||
|
if (profile) profile->Duplicated (); // mark router as duplicated in profile
|
||||||
|
});
|
||||||
else
|
else
|
||||||
LogPrint (eLogInfo, "NTCP2: Host mismatch between published address ", addr->host, " and actual endpoint ", m_RemoteEndpoint.address ());
|
LogPrint (eLogInfo, "NTCP2: Host mismatch between published address ", addr->host, " and actual endpoint ", m_RemoteEndpoint.address ());
|
||||||
SendTerminationAndTerminate (eNTCP2Banned);
|
SendTerminationAndTerminate (eNTCP2Banned);
|
||||||
|
|
|
@ -1178,14 +1178,19 @@ namespace transport
|
||||||
LogPrint (eLogError, "SSU2: Couldn't update RouterInfo from SessionConfirmed in netdb");
|
LogPrint (eLogError, "SSU2: Couldn't update RouterInfo from SessionConfirmed in netdb");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::shared_ptr<i2p::data::RouterProfile> profile; // not null if older
|
|
||||||
|
bool isOlder = false;
|
||||||
if (ri->GetTimestamp () + i2p::data::NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL < ri1->GetTimestamp ())
|
if (ri->GetTimestamp () + i2p::data::NETDB_EXPIRATION_TIMEOUT_THRESHOLD*1000LL < ri1->GetTimestamp ())
|
||||||
{
|
{
|
||||||
// received RouterInfo is older than one in netdb
|
// received RouterInfo is older than one in netdb
|
||||||
profile = i2p::data::GetRouterProfile (ri->GetIdentHash ()); // retrieve profile
|
isOlder = true;
|
||||||
|
if (ri->HasProfile ())
|
||||||
|
{
|
||||||
|
auto profile = i2p::data::GetRouterProfile (ri->GetIdentHash ()); // retrieve profile
|
||||||
if (profile && profile->IsDuplicated ())
|
if (profile && profile->IsDuplicated ())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ri = ri1;
|
ri = ri1;
|
||||||
|
|
||||||
m_Address = m_RemoteEndpoint.address ().is_v6 () ? ri->GetSSU2V6Address () : ri->GetSSU2V4Address ();
|
m_Address = m_RemoteEndpoint.address ().is_v6 () ? ri->GetSSU2V6Address () : ri->GetSSU2V4Address ();
|
||||||
|
@ -1198,8 +1203,12 @@ namespace transport
|
||||||
(!m_RemoteEndpoint.address ().is_v6 () ||
|
(!m_RemoteEndpoint.address ().is_v6 () ||
|
||||||
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data (), m_Address->host.to_v6 ().to_bytes ().data (), 8))) // temporary address
|
memcmp (m_RemoteEndpoint.address ().to_v6 ().to_bytes ().data (), m_Address->host.to_v6 ().to_bytes ().data (), 8))) // temporary address
|
||||||
{
|
{
|
||||||
if (profile) // older router?
|
if (isOlder) // older router?
|
||||||
profile->Duplicated (); // mark router as duplicated in profile
|
i2p::data::UpdateRouterProfile (ri->GetIdentHash (),
|
||||||
|
[](std::shared_ptr<i2p::data::RouterProfile> profile)
|
||||||
|
{
|
||||||
|
if (profile) profile->Duplicated (); // mark router as duplicated in profile
|
||||||
|
});
|
||||||
else
|
else
|
||||||
LogPrint (eLogInfo, "SSU2: Host mismatch between published address ", m_Address->host,
|
LogPrint (eLogInfo, "SSU2: Host mismatch between published address ", m_Address->host,
|
||||||
" and actual endpoint ", m_RemoteEndpoint.address (), " from ", i2p::data::GetIdentHashAbbreviation (ri->GetIdentHash ()));
|
" and actual endpoint ", m_RemoteEndpoint.address (), " from ", i2p::data::GetIdentHashAbbreviation (ri->GetIdentHash ()));
|
||||||
|
|
Loading…
Reference in a new issue