Skip to content

Commit

Permalink
Explicitly enforce hysteria2 max packet size
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Jun 7, 2024
1 parent 23d0ecf commit 7694c51
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hysteria2/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7694c51

Please sign in to comment.