From f572e7fba8eeb13b448c4d01f4b6a2ed9944bd00 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Wed, 6 Dec 2023 12:02:50 +0800 Subject: [PATCH] fix: avoid gobwas/ws pbytes.GetLen panic --- transport/vmess/websocket.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transport/vmess/websocket.go b/transport/vmess/websocket.go index 43faac5a..acca049f 100644 --- a/transport/vmess/websocket.go +++ b/transport/vmess/websocket.go @@ -65,6 +65,11 @@ type WebsocketConfig struct { // Read implements net.Conn.Read() // modify from gobwas/ws/wsutil.readData func (wsc *websocketConn) Read(b []byte) (n int, err error) { + defer func() { // avoid gobwas/ws pbytes.GetLen panic + if value := recover(); value != nil { + err = fmt.Errorf("websocket error: %s", value) + } + }() var header ws.Header for { n, err = wsc.reader.Read(b)