mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-12-02 13:26:47 +00:00
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:
1 parent
810b014ee9
commit
0159cf47ed
2 files changed
+2
-2
No files matched your search
@@ -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()
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in new issue
Block a user