From fe8564f7e0b2b0d184aea0368fbdba8a83781b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 7 Jun 2024 21:15:20 +0800 Subject: [PATCH] Explicitly enforce hysteria2 max packet size --- hysteria2/packet.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hysteria2/packet.go b/hysteria2/packet.go index 5b54fce..6e39b52 100644 --- a/hysteria2/packet.go +++ b/hysteria2/packet.go @@ -177,8 +177,8 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) return net.ErrClosed default: } - if buffer.Len() > 0xffff { - return &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff} + if buffer.Len() > protocol.MaxUDPSize { + return &quic.DatagramTooLargeError{MaxDatagramPayloadSize: protocol.MaxUDPSize} } packetId := uint16(c.packetId.Add(1) % math.MaxUint16) message := allocMessage() @@ -212,8 +212,8 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) { return 0, net.ErrClosed default: } - if len(p) > 0xffff { - return 0, &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff} + if len(p) > protocol.MaxUDPSize { + return 0, &quic.DatagramTooLargeError{MaxDatagramPayloadSize: protocol.MaxUDPSize} } packetId := uint16(c.packetId.Add(1) % math.MaxUint16) message := allocMessage()