mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-24 01:46:36 +02:00
don't look for session if a packet is from same endpoint as previous
This commit is contained in:
parent
c6c414c382
commit
23907e6cb1
3 changed files with 15 additions and 14 deletions
25
SSU.cpp
25
SSU.cpp
|
@ -211,22 +211,25 @@ namespace transport
|
||||||
|
|
||||||
void SSUServer::HandleReceivedPackets (std::vector<SSUPacket *> packets)
|
void SSUServer::HandleReceivedPackets (std::vector<SSUPacket *> packets)
|
||||||
{
|
{
|
||||||
|
std::shared_ptr<SSUSession> session;
|
||||||
for (auto it1: packets)
|
for (auto it1: packets)
|
||||||
{
|
{
|
||||||
auto packet = it1;
|
auto packet = it1;
|
||||||
std::shared_ptr<SSUSession> session;
|
if (session && session->GetRemoteEndpoint () != packet->from) // we received packet for other session than previous
|
||||||
auto it = m_Sessions.find (packet->from);
|
|
||||||
if (it != m_Sessions.end ())
|
|
||||||
session = it->second;
|
|
||||||
if (!session)
|
|
||||||
{
|
{
|
||||||
session = std::make_shared<SSUSession> (*this, packet->from);
|
auto it = m_Sessions.find (packet->from);
|
||||||
session->WaitForConnect ();
|
if (it != m_Sessions.end ())
|
||||||
|
session = it->second;
|
||||||
|
if (!session)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
session = std::make_shared<SSUSession> (*this, packet->from);
|
||||||
m_Sessions[packet->from] = session;
|
session->WaitForConnect ();
|
||||||
}
|
{
|
||||||
LogPrint ("New SSU session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created");
|
std::unique_lock<std::mutex> l(m_SessionsMutex);
|
||||||
|
m_Sessions[packet->from] = session;
|
||||||
|
}
|
||||||
|
LogPrint ("New SSU session from ", packet->from.address ().to_string (), ":", packet->from.port (), " created");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
session->ProcessNextMessage (packet->buf, packet->len, packet->from);
|
session->ProcessNextMessage (packet->buf, packet->len, packet->from);
|
||||||
delete packet;
|
delete packet;
|
||||||
|
|
|
@ -152,8 +152,7 @@ namespace transport
|
||||||
uint32_t fragmentInfo = bufbe32toh (frag); // fragment info
|
uint32_t fragmentInfo = bufbe32toh (frag); // fragment info
|
||||||
uint16_t fragmentSize = fragmentInfo & 0x1FFF; // bits 0 - 13
|
uint16_t fragmentSize = fragmentInfo & 0x1FFF; // bits 0 - 13
|
||||||
bool isLast = fragmentInfo & 0x010000; // bit 16
|
bool isLast = fragmentInfo & 0x010000; // bit 16
|
||||||
uint8_t fragmentNum = fragmentInfo >> 17; // bits 23 - 17
|
uint8_t fragmentNum = fragmentInfo >> 17; // bits 23 - 17
|
||||||
LogPrint (eLogDebug, "SSU data fragment ", (int)fragmentNum, " of message ", msgID, " size=", (int)fragmentSize, isLast ? " last" : " non-last");
|
|
||||||
if (fragmentSize >= SSU_V4_MAX_PACKET_SIZE)
|
if (fragmentSize >= SSU_V4_MAX_PACKET_SIZE)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Fragment size ", fragmentSize, "exceeds max SSU packet size");
|
LogPrint (eLogError, "Fragment size ", fragmentSize, "exceeds max SSU packet size");
|
||||||
|
|
|
@ -130,7 +130,6 @@ namespace transport
|
||||||
switch (header->GetPayloadType ())
|
switch (header->GetPayloadType ())
|
||||||
{
|
{
|
||||||
case PAYLOAD_TYPE_DATA:
|
case PAYLOAD_TYPE_DATA:
|
||||||
LogPrint (eLogDebug, "SSU data received");
|
|
||||||
ProcessData (buf + sizeof (SSUHeader), len - sizeof (SSUHeader));
|
ProcessData (buf + sizeof (SSUHeader), len - sizeof (SSUHeader));
|
||||||
break;
|
break;
|
||||||
case PAYLOAD_TYPE_SESSION_REQUEST:
|
case PAYLOAD_TYPE_SESSION_REQUEST:
|
||||||
|
|
Loading…
Add table
Reference in a new issue