From 01f8ce81acb790d6e6219c49564a97e444735738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 8 Apr 2024 11:03:25 +0800 Subject: [PATCH] Fix fragUDPMessage --- hysteria/packet.go | 4 ++-- hysteria2/packet.go | 4 ++-- tuic/packet.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hysteria/packet.go b/hysteria/packet.go index 18d92c6..18110e1 100644 --- a/hysteria/packet.go +++ b/hysteria/packet.go @@ -88,12 +88,12 @@ func (m *udpMessage) headerSize() int { } func fragUDPMessage(message *udpMessage, maxPacketSize int) []*udpMessage { - if message.data.Len() <= maxPacketSize { + udpMTU := maxPacketSize - message.headerSize() + if message.data.Len() <= udpMTU { return []*udpMessage{message} } var fragments []*udpMessage originPacket := message.data.Bytes() - udpMTU := maxPacketSize - message.headerSize() for remaining := len(originPacket); remaining > 0; remaining -= udpMTU { fragment := allocMessage() *fragment = *message diff --git a/hysteria2/packet.go b/hysteria2/packet.go index b1cac0e..07887b0 100644 --- a/hysteria2/packet.go +++ b/hysteria2/packet.go @@ -84,12 +84,12 @@ func (m *udpMessage) headerSize() int { } func fragUDPMessage(message *udpMessage, maxPacketSize int) []*udpMessage { - if message.data.Len() <= maxPacketSize { + udpMTU := maxPacketSize - message.headerSize() + if message.data.Len() <= udpMTU { return []*udpMessage{message} } var fragments []*udpMessage originPacket := message.data.Bytes() - udpMTU := maxPacketSize - message.headerSize() for remaining := len(originPacket); remaining > 0; remaining -= udpMTU { fragment := allocMessage() *fragment = *message diff --git a/tuic/packet.go b/tuic/packet.go index c9aa54e..1a358fa 100644 --- a/tuic/packet.go +++ b/tuic/packet.go @@ -86,12 +86,12 @@ func (m *udpMessage) headerSize() int { } func fragUDPMessage(message *udpMessage, maxPacketSize int) []*udpMessage { - if message.data.Len() <= maxPacketSize { + udpMTU := maxPacketSize - message.headerSize() + if message.data.Len() <= udpMTU { return []*udpMessage{message} } var fragments []*udpMessage originPacket := message.data.Bytes() - udpMTU := maxPacketSize - message.headerSize() for remaining := len(originPacket); remaining > 0; remaining -= udpMTU { fragment := allocMessage() *fragment = *message