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