mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-08-26 10:10:24 +01:00
don't add signature to ping message if i2p.streaming.dontSign
This commit is contained in:
parent
aca5f35fa0
commit
20ba95ee52
1 changed files with 18 additions and 12 deletions
|
@ -1218,7 +1218,8 @@ namespace stream
|
||||||
size += 4; // sendStreamID
|
size += 4; // sendStreamID
|
||||||
memset (packet + size, 0, 14);
|
memset (packet + size, 0, 14);
|
||||||
size += 14; // all zeroes
|
size += 14; // all zeroes
|
||||||
uint16_t flags = PACKET_FLAG_ECHO | PACKET_FLAG_SIGNATURE_INCLUDED | PACKET_FLAG_FROM_INCLUDED;
|
uint16_t flags = PACKET_FLAG_ECHO | PACKET_FLAG_FROM_INCLUDED;
|
||||||
|
if (!m_DontSign) flags |= PACKET_FLAG_SIGNATURE_INCLUDED;
|
||||||
bool isOfflineSignature = m_LocalDestination.GetOwner ()->GetPrivateKeys ().IsOfflineSignature ();
|
bool isOfflineSignature = m_LocalDestination.GetOwner ()->GetPrivateKeys ().IsOfflineSignature ();
|
||||||
if (isOfflineSignature) flags |= PACKET_FLAG_OFFLINE_SIGNATURE;
|
if (isOfflineSignature) flags |= PACKET_FLAG_OFFLINE_SIGNATURE;
|
||||||
htobe16buf (packet + size, flags);
|
htobe16buf (packet + size, flags);
|
||||||
|
@ -1229,17 +1230,22 @@ namespace stream
|
||||||
size += 2; // options size
|
size += 2; // options size
|
||||||
m_LocalDestination.GetOwner ()->GetIdentity ()->ToBuffer (packet + size, identityLen);
|
m_LocalDestination.GetOwner ()->GetIdentity ()->ToBuffer (packet + size, identityLen);
|
||||||
size += identityLen; // from
|
size += identityLen; // from
|
||||||
if (isOfflineSignature)
|
if (m_DontSign)
|
||||||
|
htobe16buf (optionsSize, packet + size - 2 - optionsSize); // actual options size
|
||||||
|
else
|
||||||
{
|
{
|
||||||
const auto& offlineSignature = m_LocalDestination.GetOwner ()->GetPrivateKeys ().GetOfflineSignature ();
|
if (isOfflineSignature)
|
||||||
memcpy (packet + size, offlineSignature.data (), offlineSignature.size ());
|
{
|
||||||
size += offlineSignature.size (); // offline signature
|
const auto& offlineSignature = m_LocalDestination.GetOwner ()->GetPrivateKeys ().GetOfflineSignature ();
|
||||||
|
memcpy (packet + size, offlineSignature.data (), offlineSignature.size ());
|
||||||
|
size += offlineSignature.size (); // offline signature
|
||||||
|
}
|
||||||
|
uint8_t * signature = packet + size; // set it later
|
||||||
|
memset (signature, 0, signatureLen); // zeroes for now
|
||||||
|
size += signatureLen; // signature
|
||||||
|
htobe16buf (optionsSize, packet + size - 2 - optionsSize); // actual options size
|
||||||
|
m_LocalDestination.GetOwner ()->Sign (packet, size, signature);
|
||||||
}
|
}
|
||||||
uint8_t * signature = packet + size; // set it later
|
|
||||||
memset (signature, 0, signatureLen); // zeroes for now
|
|
||||||
size += signatureLen; // signature
|
|
||||||
htobe16buf (optionsSize, packet + size - 2 - optionsSize); // actual options size
|
|
||||||
m_LocalDestination.GetOwner ()->Sign (packet, size, signature);
|
|
||||||
p.len = size;
|
p.len = size;
|
||||||
SendPackets (std::vector<Packet *> { &p });
|
SendPackets (std::vector<Packet *> { &p });
|
||||||
LogPrint (eLogDebug, "Streaming: Ping of ", p.len, " bytes sent");
|
LogPrint (eLogDebug, "Streaming: Ping of ", p.len, " bytes sent");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue