Skip to content

Commit fe8564f

Browse files
committed
Explicitly enforce hysteria2 max packet size
1 parent d8b6f04 commit fe8564f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

hysteria2/packet.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ func (c *udpPacketConn) WritePacket(buffer *buf.Buffer, destination M.Socksaddr)
177177
return net.ErrClosed
178178
default:
179179
}
180-
if buffer.Len() > 0xffff {
181-
return &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff}
180+
if buffer.Len() > protocol.MaxUDPSize {
181+
return &quic.DatagramTooLargeError{MaxDatagramPayloadSize: protocol.MaxUDPSize}
182182
}
183183
packetId := uint16(c.packetId.Add(1) % math.MaxUint16)
184184
message := allocMessage()
@@ -212,8 +212,8 @@ func (c *udpPacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) {
212212
return 0, net.ErrClosed
213213
default:
214214
}
215-
if len(p) > 0xffff {
216-
return 0, &quic.DatagramTooLargeError{MaxDatagramPayloadSize: 0xffff}
215+
if len(p) > protocol.MaxUDPSize {
216+
return 0, &quic.DatagramTooLargeError{MaxDatagramPayloadSize: protocol.MaxUDPSize}
217217
}
218218
packetId := uint16(c.packetId.Add(1) % math.MaxUint16)
219219
message := allocMessage()

0 commit comments

Comments
 (0)