mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
don't copy I2NP messages to NTCP2 frame
This commit is contained in:
parent
abc4f6c70b
commit
95ab68acd1
|
@ -1024,22 +1024,16 @@ namespace transport
|
|||
{
|
||||
if (!m_SendQueue.empty ())
|
||||
{
|
||||
auto buf = m_Server.NewNTCP2FrameBuffer ();
|
||||
uint8_t * payload = buf->data ();
|
||||
std::vector<std::shared_ptr<I2NPMessage> > msgs;
|
||||
size_t s = 0;
|
||||
// add I2NP blocks
|
||||
while (!m_SendQueue.empty ())
|
||||
{
|
||||
auto msg = m_SendQueue.front ();
|
||||
size_t len = msg->GetNTCP2Length ();
|
||||
if (s + len + 3 <= NTCP2_UNENCRYPTED_FRAME_MAX_SIZE) // 3 bytes block header
|
||||
{
|
||||
payload[s] = eNTCP2BlkI2NPMessage; // blk
|
||||
htobe16buf (payload + s + 1, len); // size
|
||||
s += 3;
|
||||
msg->ToNTCP2 ();
|
||||
memcpy (payload + s, msg->GetNTCP2Header (), len);
|
||||
s += len;
|
||||
msgs.push_back (msg);
|
||||
s += (len + 3);
|
||||
m_SendQueue.pop_front ();
|
||||
}
|
||||
else if (len + 3 > NTCP2_UNENCRYPTED_FRAME_MAX_SIZE)
|
||||
|
@ -1050,11 +1044,7 @@ namespace transport
|
|||
else
|
||||
break;
|
||||
}
|
||||
// add padding block
|
||||
s += CreatePaddingBlock (s, payload + s, NTCP2_UNENCRYPTED_FRAME_MAX_SIZE - s);
|
||||
// send
|
||||
SendNextFrame (payload, s);
|
||||
m_Server.DeleteNTCP2FrameBuffer (buf);
|
||||
SendI2NPMsgs (msgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,6 @@ namespace transport
|
|||
// RouterInfo flags
|
||||
const uint8_t NTCP2_ROUTER_INFO_FLAG_REQUEST_FLOOD = 0x01;
|
||||
|
||||
typedef std::array<uint8_t, NTCP2_UNENCRYPTED_FRAME_MAX_SIZE> NTCP2FrameBuffer;
|
||||
struct NTCP2Establisher
|
||||
{
|
||||
NTCP2Establisher ();
|
||||
|
@ -236,9 +235,6 @@ namespace transport
|
|||
|
||||
void Connect(const boost::asio::ip::address & address, uint16_t port, std::shared_ptr<NTCP2Session> conn);
|
||||
|
||||
NTCP2FrameBuffer * NewNTCP2FrameBuffer () { return m_NTCP2FrameBuffersPool.Acquire(); }
|
||||
void DeleteNTCP2FrameBuffer (NTCP2FrameBuffer * buf) { return m_NTCP2FrameBuffersPool.Release(buf); }
|
||||
|
||||
private:
|
||||
|
||||
void Run ();
|
||||
|
@ -262,8 +258,6 @@ namespace transport
|
|||
std::map<i2p::data::IdentHash, std::shared_ptr<NTCP2Session> > m_NTCP2Sessions;
|
||||
std::list<std::shared_ptr<NTCP2Session> > m_PendingIncomingSessions;
|
||||
|
||||
i2p::util::MemoryPool<NTCP2FrameBuffer> m_NTCP2FrameBuffersPool;
|
||||
|
||||
public:
|
||||
|
||||
// for HTTP/I2PControl
|
||||
|
|
Loading…
Reference in a new issue