mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-08 22:13:48 +01:00
adjust MTU for incoming SSU sessions
This commit is contained in:
parent
cb46d63058
commit
1441c1371b
3 changed files with 38 additions and 20 deletions
1
SSU.cpp
1
SSU.cpp
|
@ -236,6 +236,7 @@ namespace ssu
|
||||||
i2p::data::Identity ident;
|
i2p::data::Identity ident;
|
||||||
ident.FromBuffer (payload, identitySize);
|
ident.FromBuffer (payload, identitySize);
|
||||||
m_RemoteIdent = ident.Hash ();
|
m_RemoteIdent = ident.Hash ();
|
||||||
|
m_Data.UpdatePacketSize (m_RemoteIdent);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint ("SSU unexpected identity size ", identitySize);
|
LogPrint ("SSU unexpected identity size ", identitySize);
|
||||||
|
|
33
SSUData.cpp
33
SSUData.cpp
|
@ -2,6 +2,7 @@
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
|
#include "NetDb.h"
|
||||||
#include "SSU.h"
|
#include "SSU.h"
|
||||||
#include "SSUData.h"
|
#include "SSUData.h"
|
||||||
|
|
||||||
|
@ -15,8 +16,24 @@ namespace ssu
|
||||||
m_PacketSize = SSU_MAX_PACKET_SIZE;
|
m_PacketSize = SSU_MAX_PACKET_SIZE;
|
||||||
auto remoteRouter = session.GetRemoteRouter ();
|
auto remoteRouter = session.GetRemoteRouter ();
|
||||||
if (remoteRouter)
|
if (remoteRouter)
|
||||||
|
AdjustPacketSize (*remoteRouter);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSUData::~SSUData ()
|
||||||
{
|
{
|
||||||
auto ssuAddress = remoteRouter->GetSSUAddress ();
|
for (auto it: m_IncomleteMessages)
|
||||||
|
if (it.second)
|
||||||
|
{
|
||||||
|
DeleteI2NPMessage (it.second->msg);
|
||||||
|
delete it.second;
|
||||||
|
}
|
||||||
|
for (auto it: m_SentMessages)
|
||||||
|
delete it.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSUData::AdjustPacketSize (const i2p::data::RouterInfo& remoteRouter)
|
||||||
|
{
|
||||||
|
auto ssuAddress = remoteRouter.GetSSUAddress ();
|
||||||
if (ssuAddress && ssuAddress->mtu)
|
if (ssuAddress && ssuAddress->mtu)
|
||||||
{
|
{
|
||||||
m_PacketSize = ssuAddress->mtu - IPV4_HEADER_SIZE - UDP_HEADER_SIZE;
|
m_PacketSize = ssuAddress->mtu - IPV4_HEADER_SIZE - UDP_HEADER_SIZE;
|
||||||
|
@ -35,18 +52,12 @@ namespace ssu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SSUData::~SSUData ()
|
void SSUData::UpdatePacketSize (const i2p::data::IdentHash& remoteIdent)
|
||||||
{
|
{
|
||||||
for (auto it: m_IncomleteMessages)
|
auto routerInfo = i2p::data::netdb.FindRouter (remoteIdent);
|
||||||
if (it.second)
|
if (routerInfo)
|
||||||
{
|
AdjustPacketSize (*routerInfo);
|
||||||
DeleteI2NPMessage (it.second->msg);
|
|
||||||
delete it.second;
|
|
||||||
}
|
|
||||||
for (auto it: m_SentMessages)
|
|
||||||
delete it.second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUData::ProcessSentMessageAck (uint32_t msgID)
|
void SSUData::ProcessSentMessageAck (uint32_t msgID)
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
|
#include "Identity.h"
|
||||||
|
#include "RouterInfo.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
|
@ -78,6 +80,8 @@ namespace ssu
|
||||||
void ProcessMessage (uint8_t * buf, size_t len);
|
void ProcessMessage (uint8_t * buf, size_t len);
|
||||||
void Send (i2p::I2NPMessage * msg);
|
void Send (i2p::I2NPMessage * msg);
|
||||||
|
|
||||||
|
void UpdatePacketSize (const i2p::data::IdentHash& remoteIdent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void SendMsgAck (uint32_t msgID);
|
void SendMsgAck (uint32_t msgID);
|
||||||
|
@ -89,6 +93,8 @@ namespace ssu
|
||||||
void ScheduleResend ();
|
void ScheduleResend ();
|
||||||
void HandleResendTimer (const boost::system::error_code& ecode);
|
void HandleResendTimer (const boost::system::error_code& ecode);
|
||||||
|
|
||||||
|
void AdjustPacketSize (const i2p::data::RouterInfo& remoteRouter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SSUSession& m_Session;
|
SSUSession& m_Session;
|
||||||
|
|
Loading…
Add table
Reference in a new issue