fix: restore hysteria v1 udp handling (#3178)

Fixed two Hysteria v1 UDP regressions introduced in 48c1b1cdb2 :
- Mark UDP session requests correctly with UDP: true.
- Initialize the packet buffer with zero length and preallocated capacity to prevent leading zero bytes.
This commit is contained in:
Chenx Dust authored and GitHub committed 2026-09-04 22:06:21 +08:00
1 parent 810b014ee9
commit 0159cf47ed
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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)))