mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
don't create identity if presented in netdb already
This commit is contained in:
parent
9030b3e04c
commit
8a2c4ab3de
@ -346,12 +346,15 @@ namespace transport
|
|||||||
m_Decryption.Decrypt (m_ReceiveBuffer, bytes_transferred, m_ReceiveBuffer);
|
m_Decryption.Decrypt (m_ReceiveBuffer, bytes_transferred, m_ReceiveBuffer);
|
||||||
uint8_t * buf = m_ReceiveBuffer;
|
uint8_t * buf = m_ReceiveBuffer;
|
||||||
uint16_t size = bufbe16toh (buf);
|
uint16_t size = bufbe16toh (buf);
|
||||||
SetRemoteIdentity (std::make_shared<i2p::data::IdentityEx> (buf + 2, size));
|
auto identity = std::make_shared<i2p::data::IdentityEx> (buf + 2, size);
|
||||||
if (m_Server.FindNTCPSession (m_RemoteIdentity->GetIdentHash ()))
|
if (m_Server.FindNTCPSession (identity->GetIdentHash ()))
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "NTCP: session already exists");
|
LogPrint (eLogInfo, "NTCP: session already exists");
|
||||||
Terminate ();
|
Terminate ();
|
||||||
}
|
}
|
||||||
|
auto existing = i2p::data::netdb.FindRouter (identity->GetIdentHash ()); // check if exists already
|
||||||
|
SetRemoteIdentity (existing ? existing->GetRouterIdentity () : identity);
|
||||||
|
|
||||||
size_t expectedSize = size + 2/*size*/ + 4/*timestamp*/ + m_RemoteIdentity->GetSignatureLen ();
|
size_t expectedSize = size + 2/*size*/ + 4/*timestamp*/ + m_RemoteIdentity->GetSignatureLen ();
|
||||||
size_t paddingLen = expectedSize & 0x0F;
|
size_t paddingLen = expectedSize & 0x0F;
|
||||||
if (paddingLen) paddingLen = (16 - paddingLen);
|
if (paddingLen) paddingLen = (16 - paddingLen);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
#include "RouterContext.h"
|
#include "RouterContext.h"
|
||||||
#include "Transports.h"
|
#include "Transports.h"
|
||||||
|
#include "NetDb.h"
|
||||||
#include "SSU.h"
|
#include "SSU.h"
|
||||||
#include "SSUSession.h"
|
#include "SSUSession.h"
|
||||||
|
|
||||||
@ -317,7 +318,9 @@ namespace transport
|
|||||||
payload++; // identity fragment info
|
payload++; // identity fragment info
|
||||||
uint16_t identitySize = bufbe16toh (payload);
|
uint16_t identitySize = bufbe16toh (payload);
|
||||||
payload += 2; // size of identity fragment
|
payload += 2; // size of identity fragment
|
||||||
SetRemoteIdentity (std::make_shared<i2p::data::IdentityEx> (payload, identitySize));
|
auto identity = std::make_shared<i2p::data::IdentityEx> (payload, identitySize);
|
||||||
|
auto existing = i2p::data::netdb.FindRouter (identity->GetIdentHash ()); // check if exists already
|
||||||
|
SetRemoteIdentity (existing ? existing->GetRouterIdentity () : identity);
|
||||||
m_Data.UpdatePacketSize (m_RemoteIdentity->GetIdentHash ());
|
m_Data.UpdatePacketSize (m_RemoteIdentity->GetIdentHash ());
|
||||||
payload += identitySize; // identity
|
payload += identitySize; // identity
|
||||||
auto ts = i2p::util::GetSecondsSinceEpoch ();
|
auto ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user