fix bug with treshold 0 never compressing instead of always compressing

This commit is contained in:
adman
2026-04-12 23:16:19 +02:00
parent 9f6b1f6bcf
commit bb89730781
+2 -2
View File
@@ -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 {