mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
fixed #1256 I2NP messages up to 64K
This commit is contained in:
parent
9e12cff317
commit
a97300f8be
@ -36,7 +36,7 @@ namespace i2p
|
||||
|
||||
std::shared_ptr<I2NPMessage> NewI2NPMessage (size_t len)
|
||||
{
|
||||
return (len < I2NP_MAX_SHORT_MESSAGE_SIZE/2) ? NewI2NPShortMessage () : NewI2NPMessage ();
|
||||
return (len < I2NP_MAX_SHORT_MESSAGE_SIZE - I2NP_HEADER_SIZE - 2) ? NewI2NPShortMessage () : NewI2NPMessage ();
|
||||
}
|
||||
|
||||
void I2NPMessage::FillI2NPMessageHeader (I2NPMessageType msgType, uint32_t replyMsgID)
|
||||
|
@ -106,7 +106,7 @@ namespace tunnel
|
||||
class TunnelPool;
|
||||
}
|
||||
|
||||
const size_t I2NP_MAX_MESSAGE_SIZE = 32768;
|
||||
const size_t I2NP_MAX_MESSAGE_SIZE = 62708;
|
||||
const size_t I2NP_MAX_SHORT_MESSAGE_SIZE = 4096;
|
||||
const unsigned int I2NP_MESSAGE_EXPIRATION_TIMEOUT = 8000; // in milliseconds (as initial RTT)
|
||||
const unsigned int I2NP_MESSAGE_CLOCK_SKEW = 60*1000; // 1 minute in milliseconds
|
||||
|
@ -900,6 +900,11 @@ namespace transport
|
||||
case eNTCP2BlkI2NPMessage:
|
||||
{
|
||||
LogPrint (eLogDebug, "NTCP2: I2NP");
|
||||
if (size > I2NP_MAX_MESSAGE_SIZE)
|
||||
{
|
||||
LogPrint (eLogError, "NTCP2: I2NP block is too long ", size);
|
||||
break;
|
||||
}
|
||||
auto nextMsg = NewI2NPMessage (size);
|
||||
nextMsg->len = nextMsg->offset + size + 7; // 7 more bytes for full I2NP header
|
||||
memcpy (nextMsg->GetNTCP2Header (), frame + offset, size);
|
||||
@ -993,6 +998,11 @@ namespace transport
|
||||
s += len;
|
||||
m_SendQueue.pop_front ();
|
||||
}
|
||||
else if (len + 3 > NTCP2_UNENCRYPTED_FRAME_MAX_SIZE)
|
||||
{
|
||||
LogPrint (eLogError, "NTCP2: I2NP message of size ", len, " can't be sent. Dropped");
|
||||
m_SendQueue.pop_front ();
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
@ -1122,7 +1132,7 @@ namespace transport
|
||||
auto conn = std::make_shared<NTCP2Session> (*this);
|
||||
m_NTCP2V6Acceptor->async_accept(conn->GetSocket (), std::bind (&NTCP2Server::HandleAcceptV6, this, conn, std::placeholders::_1));
|
||||
} catch ( std::exception & ex ) {
|
||||
LogPrint(eLogError, "NTCP: failed to bind to ip6 port ", address->port);
|
||||
LogPrint(eLogError, "NTCP2: failed to bind to ip6 port ", address->port);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user