mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
set best compression for RouterInfo
This commit is contained in:
parent
1eead0e885
commit
dff510c181
@ -107,7 +107,10 @@ namespace data
|
||||
m_Deflator.avail_out = outLen;
|
||||
int err;
|
||||
if ((err = deflate (&m_Deflator, Z_FINISH)) == Z_STREAM_END)
|
||||
{
|
||||
out[9] = 0xff; // OS is always unknown
|
||||
return outLen - m_Deflator.avail_out;
|
||||
}
|
||||
// else
|
||||
LogPrint (eLogError, "Gzip: Deflate error ", err);
|
||||
return 0;
|
||||
@ -115,7 +118,7 @@ namespace data
|
||||
|
||||
size_t GzipNoCompression (const uint8_t * in, uint16_t inLen, uint8_t * out, size_t outLen)
|
||||
{
|
||||
static const uint8_t gzipHeader[11] = { 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x01 };
|
||||
static const uint8_t gzipHeader[11] = { 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0x01 };
|
||||
if (outLen < (size_t)inLen + 23) return 0;
|
||||
memcpy (out, gzipHeader, 11);
|
||||
htole16buf (out + 11, inLen);
|
||||
|
@ -250,6 +250,7 @@ namespace i2p
|
||||
buf += 2;
|
||||
m->len += (buf - payload); // payload size
|
||||
i2p::data::GzipDeflator deflator;
|
||||
deflator.SetCompressionLevel (Z_BEST_COMPRESSION);
|
||||
size_t size = deflator.Deflate (router->GetBuffer (), router->GetBufferLen (), buf, m->maxLen -m->len);
|
||||
if (size)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user