mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-27 11:17:49 +02:00
pass local destination by pointer
This commit is contained in:
parent
6e32c389b1
commit
f357a5864c
8 changed files with 56 additions and 23 deletions
18
LeaseSet.cpp
18
LeaseSet.cpp
|
@ -22,11 +22,17 @@ namespace data
|
|||
LeaseSet::LeaseSet (const i2p::tunnel::TunnelPool& pool)
|
||||
{
|
||||
// header
|
||||
const i2p::data::LocalDestination& localDestination = pool.GetLocalDestination ();
|
||||
m_BufferLen = localDestination.GetIdentity ().ToBuffer (m_Buffer, MAX_LS_BUFFER_SIZE);
|
||||
memcpy (m_Buffer + m_BufferLen, localDestination.GetEncryptionPublicKey (), 256);
|
||||
const i2p::data::LocalDestination * localDestination = pool.GetLocalDestination ();
|
||||
if (!localDestination)
|
||||
{
|
||||
m_BufferLen = 0;
|
||||
LogPrint (eLogError, "Destination for local LeaseSet doesn't exist");
|
||||
return;
|
||||
}
|
||||
m_BufferLen = localDestination->GetIdentity ().ToBuffer (m_Buffer, MAX_LS_BUFFER_SIZE);
|
||||
memcpy (m_Buffer + m_BufferLen, localDestination->GetEncryptionPublicKey (), 256);
|
||||
m_BufferLen += 256;
|
||||
auto signingKeyLen = localDestination.GetIdentity ().GetSigningPublicKeyLen ();
|
||||
auto signingKeyLen = localDestination->GetIdentity ().GetSigningPublicKeyLen ();
|
||||
memset (m_Buffer + m_BufferLen, 0, signingKeyLen);
|
||||
m_BufferLen += signingKeyLen;
|
||||
auto tunnels = pool.GetInboundTunnels (5); // 5 tunnels maximum
|
||||
|
@ -44,8 +50,8 @@ namespace data
|
|||
m_BufferLen += sizeof (Lease);
|
||||
}
|
||||
// signature
|
||||
localDestination.Sign (m_Buffer, m_BufferLen, m_Buffer + m_BufferLen);
|
||||
m_BufferLen += localDestination.GetIdentity ().GetSignatureLen ();
|
||||
localDestination->Sign (m_Buffer, m_BufferLen, m_Buffer + m_BufferLen);
|
||||
m_BufferLen += localDestination->GetIdentity ().GetSignatureLen ();
|
||||
LogPrint ("Local LeaseSet of ", tunnels.size (), " leases created");
|
||||
|
||||
ReadFromBuffer ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue