|
|
@ -1024,22 +1024,16 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_SendQueue.empty ()) |
|
|
|
if (!m_SendQueue.empty ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto buf = m_Server.NewNTCP2FrameBuffer (); |
|
|
|
std::vector<std::shared_ptr<I2NPMessage> > msgs; |
|
|
|
uint8_t * payload = buf->data (); |
|
|
|
|
|
|
|
size_t s = 0; |
|
|
|
size_t s = 0; |
|
|
|
// add I2NP blocks
|
|
|
|
|
|
|
|
while (!m_SendQueue.empty ()) |
|
|
|
while (!m_SendQueue.empty ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto msg = m_SendQueue.front (); |
|
|
|
auto msg = m_SendQueue.front (); |
|
|
|
size_t len = msg->GetNTCP2Length (); |
|
|
|
size_t len = msg->GetNTCP2Length (); |
|
|
|
if (s + len + 3 <= NTCP2_UNENCRYPTED_FRAME_MAX_SIZE) // 3 bytes block header
|
|
|
|
if (s + len + 3 <= NTCP2_UNENCRYPTED_FRAME_MAX_SIZE) // 3 bytes block header
|
|
|
|
{ |
|
|
|
{ |
|
|
|
payload[s] = eNTCP2BlkI2NPMessage; // blk
|
|
|
|
msgs.push_back (msg); |
|
|
|
htobe16buf (payload + s + 1, len); // size
|
|
|
|
s += (len + 3); |
|
|
|
s += 3; |
|
|
|
|
|
|
|
msg->ToNTCP2 (); |
|
|
|
|
|
|
|
memcpy (payload + s, msg->GetNTCP2Header (), len); |
|
|
|
|
|
|
|
s += len; |
|
|
|
|
|
|
|
m_SendQueue.pop_front (); |
|
|
|
m_SendQueue.pop_front (); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (len + 3 > NTCP2_UNENCRYPTED_FRAME_MAX_SIZE) |
|
|
|
else if (len + 3 > NTCP2_UNENCRYPTED_FRAME_MAX_SIZE) |
|
|
@ -1050,11 +1044,7 @@ namespace transport |
|
|
|
else |
|
|
|
else |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
// add padding block
|
|
|
|
SendI2NPMsgs (msgs); |
|
|
|
s += CreatePaddingBlock (s, payload + s, NTCP2_UNENCRYPTED_FRAME_MAX_SIZE - s); |
|
|
|
|
|
|
|
// send
|
|
|
|
|
|
|
|
SendNextFrame (payload, s); |
|
|
|
|
|
|
|
m_Server.DeleteNTCP2FrameBuffer (buf); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|