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;
|
m_Deflator.avail_out = outLen;
|
||||||
int err;
|
int err;
|
||||||
if ((err = deflate (&m_Deflator, Z_FINISH)) == Z_STREAM_END)
|
if ((err = deflate (&m_Deflator, Z_FINISH)) == Z_STREAM_END)
|
||||||
|
{
|
||||||
|
out[9] = 0xff; // OS is always unknown
|
||||||
return outLen - m_Deflator.avail_out;
|
return outLen - m_Deflator.avail_out;
|
||||||
|
}
|
||||||
// else
|
// else
|
||||||
LogPrint (eLogError, "Gzip: Deflate error ", err);
|
LogPrint (eLogError, "Gzip: Deflate error ", err);
|
||||||
return 0;
|
return 0;
|
||||||
@ -115,7 +118,7 @@ namespace data
|
|||||||
|
|
||||||
size_t GzipNoCompression (const uint8_t * in, uint16_t inLen, uint8_t * out, size_t outLen)
|
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;
|
if (outLen < (size_t)inLen + 23) return 0;
|
||||||
memcpy (out, gzipHeader, 11);
|
memcpy (out, gzipHeader, 11);
|
||||||
htole16buf (out + 11, inLen);
|
htole16buf (out + 11, inLen);
|
||||||
|
@ -250,6 +250,7 @@ namespace i2p
|
|||||||
buf += 2;
|
buf += 2;
|
||||||
m->len += (buf - payload); // payload size
|
m->len += (buf - payload); // payload size
|
||||||
i2p::data::GzipDeflator deflator;
|
i2p::data::GzipDeflator deflator;
|
||||||
|
deflator.SetCompressionLevel (Z_BEST_COMPRESSION);
|
||||||
size_t size = deflator.Deflate (router->GetBuffer (), router->GetBufferLen (), buf, m->maxLen -m->len);
|
size_t size = deflator.Deflate (router->GetBuffer (), router->GetBufferLen (), buf, m->maxLen -m->len);
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user