set best compression for RouterInfo

This commit is contained in:
orignal 2020-05-03 09:27:17 -04:00
parent 1eead0e885
commit dff510c181
2 changed files with 5 additions and 1 deletions

View File

@ -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);

View File

@ -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)
{