mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
send DateTime together with RouterInfo
This commit is contained in:
parent
4d0ad47491
commit
4f3a416e37
@ -1142,12 +1142,17 @@ namespace transport
|
||||
{
|
||||
if (!IsEstablished ()) return;
|
||||
auto riLen = i2p::context.GetRouterInfo ().GetBufferLen ();
|
||||
size_t payloadLen = riLen + 4; // 3 bytes block header + 1 byte RI flag
|
||||
size_t payloadLen = riLen + 4 + 1 + 7; // 3 bytes block header + 1 byte RI flag + 7 bytes DateTime
|
||||
m_NextSendBuffer = new uint8_t[payloadLen + 16 + 2 + 64]; // up to 64 bytes padding
|
||||
m_NextSendBuffer[2] = eNTCP2BlkRouterInfo;
|
||||
htobe16buf (m_NextSendBuffer + 3, riLen + 1); // size
|
||||
m_NextSendBuffer[5] = 0; // flag
|
||||
memcpy (m_NextSendBuffer + 6, i2p::context.GetRouterInfo ().GetBuffer (), riLen);
|
||||
// DateTime block
|
||||
m_NextSendBuffer[2] = eNTCP2BlkDateTime;
|
||||
htobe16buf (m_NextSendBuffer + 3, 4);
|
||||
htobe32buf (m_NextSendBuffer + 5, (i2p::util::GetMillisecondsSinceEpoch () + 500)/1000);
|
||||
// RouterInfo block
|
||||
m_NextSendBuffer[9] = eNTCP2BlkRouterInfo;
|
||||
htobe16buf (m_NextSendBuffer + 10, riLen + 1); // size
|
||||
m_NextSendBuffer[12] = 0; // flag
|
||||
memcpy (m_NextSendBuffer + 13, i2p::context.GetRouterInfo ().GetBuffer (), riLen);
|
||||
// padding block
|
||||
auto paddingSize = CreatePaddingBlock (payloadLen, m_NextSendBuffer + 2 + payloadLen, 64);
|
||||
payloadLen += paddingSize;
|
||||
|
Loading…
Reference in New Issue
Block a user