always compress SYN packet

This commit is contained in:
orignal 2022-10-24 19:21:58 -04:00
parent b2767304e9
commit c6e8873d57
2 changed files with 7 additions and 9 deletions

View File

@ -855,7 +855,7 @@ namespace stream
for (const auto& it: packets)
{
auto msg = m_RoutingSession->WrapSingleMessage (m_LocalDestination.CreateDataMessage (
it->GetBuffer (), it->GetLength (), m_Port, !m_RoutingSession->IsRatchets ()));
it->GetBuffer (), it->GetLength (), m_Port, !m_RoutingSession->IsRatchets (), it->IsSYN ()));
msgs.push_back (i2p::tunnel::TunnelMessageBlock
{
i2p::tunnel::eDeliveryTypeTunnel,
@ -1085,8 +1085,6 @@ namespace stream
m_Owner (owner), m_LocalPort (localPort), m_Gzip (gzip),
m_PendingIncomingTimer (m_Owner->GetService ())
{
if (m_Gzip)
m_Deflator.reset (new i2p::data::GzipDeflator);
}
StreamingDestination::~StreamingDestination ()
@ -1365,7 +1363,7 @@ namespace stream
}
std::shared_ptr<I2NPMessage> StreamingDestination::CreateDataMessage (
const uint8_t * payload, size_t len, uint16_t toPort, bool checksum)
const uint8_t * payload, size_t len, uint16_t toPort, bool checksum, bool gzip)
{
size_t size;
auto msg = m_I2NPMsgsPool.AcquireShared ();
@ -1373,8 +1371,8 @@ namespace stream
buf += 4; // reserve for lengthlength
msg->len += 4;
if (m_Gzip && m_Deflator)
size = m_Deflator->Deflate (payload, len, buf, msg->maxLen - msg->len);
if (m_Gzip || gzip)
size = m_Deflator.Deflate (payload, len, buf, msg->maxLen - msg->len);
else
size = i2p::data::GzipNoCompression (payload, len, buf, msg->maxLen - msg->len);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2021, The PurpleI2P Project
* Copyright (c) 2013-2022, The PurpleI2P Project
*
* This file is part of Purple i2pd project and licensed under BSD3
*
@ -284,7 +284,7 @@ namespace stream
uint16_t GetLocalPort () const { return m_LocalPort; };
void HandleDataMessagePayload (const uint8_t * buf, size_t len);
std::shared_ptr<I2NPMessage> CreateDataMessage (const uint8_t * payload, size_t len, uint16_t toPort, bool checksum = true);
std::shared_ptr<I2NPMessage> CreateDataMessage (const uint8_t * payload, size_t len, uint16_t toPort, bool checksum = true, bool gzip = false);
Packet * NewPacket () { return m_PacketsPool.Acquire(); }
void DeletePacket (Packet * p) { return m_PacketsPool.Release(p); }
@ -315,7 +315,7 @@ namespace stream
public:
i2p::data::GzipInflator m_Inflator;
std::unique_ptr<i2p::data::GzipDeflator> m_Deflator;
i2p::data::GzipDeflator m_Deflator;
// for HTTP only
const decltype(m_Streams)& GetStreams () const { return m_Streams; };