From 9d5f442361428c7e373603f8b6f02f36215e3efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 25 Nov 2026 20:07:41 +0800 Subject: [PATCH] Fix websocket frames split by concurrent control frames --- transport/v2raywebsocket/conn.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/transport/v2raywebsocket/conn.go b/transport/v2raywebsocket/conn.go index ecea3c55..aafacb8b 100644 --- a/transport/v2raywebsocket/conn.go +++ b/transport/v2raywebsocket/conn.go @@ -13,6 +13,7 @@ import ( C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/buf" + "github.com/sagernet/sing/common/bufio" "github.com/sagernet/sing/common/debug" E "github.com/sagernet/sing/common/exceptions" "github.com/sagernet/ws" @@ -59,7 +60,7 @@ func (c *WebsocketConn) Close() error { if c.state == ws.StateClientSide { frame = ws.MaskFrameInPlace(frame) } - ws.WriteFrame(c.Conn, frame) + c.Conn.Write(ws.MustCompileFrame(frame)) c.Conn.Close() return nil } @@ -98,12 +99,7 @@ func (c *WebsocketConn) Read(b []byte) (n int, err error) { } func (c *WebsocketConn) Write(p []byte) (n int, err error) { - err = wrapWsError(wsutil.WriteMessage(c.Conn, c.state, ws.OpBinary, p)) - if err != nil { - return - } - n = len(p) - return + return bufio.WriteBuffer(c, buf.As(p)) } func (c *WebsocketConn) RemoteAddr() net.Addr {