From bb8973078116cd1ba8fb4f4cd4d9833c0c53d9c3 Mon Sep 17 00:00:00 2001 From: adman Date: Sun, 12 Apr 2026 23:16:19 +0200 Subject: [PATCH] fix bug with treshold 0 never compressing instead of always compressing --- proto/raw_conn.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proto/raw_conn.go b/proto/raw_conn.go index 0491a20..38a8b93 100644 --- a/proto/raw_conn.go +++ b/proto/raw_conn.go @@ -38,7 +38,7 @@ func (c *RawConn) SendRaw(rawPacketBytes []byte) (err error) { //fmt.Println("send:", rawPacketBytes) var packetBytes []byte threshold := c.GetCompressionThreshold() - if threshold > 0 { + if threshold >= 0 { packetBuffer := bytes.NewBuffer(nil) if int32(len(rawPacketBytes)) >= threshold { err = proto_base.EncodeVarInt(packetBuffer, int32(len(rawPacketBytes))) @@ -95,7 +95,7 @@ func (c *RawConn) ReceiveRaw() (packetBytes []byte, err error) { return } rawPacketBuffer := bytes.NewBuffer(rawPacketBytes) - if c.GetCompressionThreshold() > 0 { + if c.GetCompressionThreshold() >= 0 { var packetLen int32 packetLen, err = proto_base.DecodeVarInt(rawPacketBuffer) if err != nil {