Explicitly enforce hysteria2 max packet size

This commit is contained in:
世界 2024-06-07 21:15:20 +08:00
parent d8b6f04cdd
commit fe8564f7e0
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -177,8 +177,8 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr)
return net.ErrClosed return net.ErrClosed
default: default:
} }
if buffer.Len() > 0xffff { if buffer.Len() > protocol.MaxUDPSize {
return &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff} return &quic.DatagramTooLargeError{MaxDatagramPayloadSize: protocol.MaxUDPSize}
} }
packetId := uint16(c.packetId.Add(1) % math.MaxUint16) packetId := uint16(c.packetId.Add(1) % math.MaxUint16)
message := allocMessage() message := allocMessage()
@ -212,8 +212,8 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
return 0, net.ErrClosed return 0, net.ErrClosed
default: default:
} }
if len(p) > 0xffff { if len(p) > protocol.MaxUDPSize {
return 0, &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff} return 0, &quic.DatagramTooLargeError{MaxDatagramPayloadSize: protocol.MaxUDPSize}
} }
packetId := uint16(c.packetId.Add(1) % math.MaxUint16) packetId := uint16(c.packetId.Add(1) % math.MaxUint16)
message := allocMessage() message := allocMessage()