From 0159cf47ed687c1945bfc6dc470d91553e993d94 Mon Sep 17 00:00:00 2001 From: Chenx Dust Date: Fri, 4 Sep 2026 22:06:21 +0800 Subject: [PATCH] fix: restore hysteria v1 udp handling (#3178) Fixed two Hysteria v1 UDP regressions introduced in 48c1b1cdb2a3e003723b6fc9504e950355efd42c : - Mark UDP session requests correctly with UDP: true. - Initialize the packet buffer with zero length and preallocated capacity to prevent leading zero bytes. --- transport/hysteria/core/client.go | 2 +- transport/hysteria/core/protocol.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/transport/hysteria/core/client.go b/transport/hysteria/core/client.go index 3e72db64d..5973e46db 100644 --- a/transport/hysteria/core/client.go +++ b/transport/hysteria/core/client.go @@ -230,7 +230,7 @@ func (c *Client) DialUDP(dialer utils.PacketDialer) (UDPConn, error) { } // Send request err = WriteClientRequest(stream, ClientRequest{ - UDP: false, + UDP: true, }) if err != nil { _ = stream.Close() diff --git a/transport/hysteria/core/protocol.go b/transport/hysteria/core/protocol.go index 77dfc2e58..0edec1d5d 100644 --- a/transport/hysteria/core/protocol.go +++ b/transport/hysteria/core/protocol.go @@ -248,7 +248,7 @@ func (m udpMessage) Size() int { } func (m udpMessage) Pack() []byte { - data := make([]byte, m.Size()) + data := make([]byte, 0, m.Size()) buffer := bytes.NewBuffer(data) _ = binary.Write(buffer, binary.BigEndian, m.SessionID) _ = binary.Write(buffer, binary.BigEndian, uint16(len(m.Host)))