From 1e1434d1debeaae3967ee4b3fb882fe63455e605 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Tue, 20 Jan 2026 14:48:59 +0800 Subject: [PATCH] chore: remove an unnecessary variable --- transport/vmess/websocket.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/transport/vmess/websocket.go b/transport/vmess/websocket.go index 0ee1b3ab..085f7dd4 100644 --- a/transport/vmess/websocket.go +++ b/transport/vmess/websocket.go @@ -42,7 +42,6 @@ type websocketWithEarlyDataConn struct { net.Conn wsWriter N.ExtendedWriter underlay net.Conn - closed bool dialed chan bool cancel context.CancelFunc ctx context.Context @@ -204,7 +203,7 @@ func (wsedc *websocketWithEarlyDataConn) Dial(earlyData []byte) error { } func (wsedc *websocketWithEarlyDataConn) Write(b []byte) (int, error) { - if wsedc.closed { + if wsedc.ctx.Err() != nil { return 0, io.ErrClosedPipe } if wsedc.Conn == nil { @@ -218,7 +217,7 @@ func (wsedc *websocketWithEarlyDataConn) Write(b []byte) (int, error) { } func (wsedc *websocketWithEarlyDataConn) WriteBuffer(buffer *buf.Buffer) error { - if wsedc.closed { + if wsedc.ctx.Err() != nil { return io.ErrClosedPipe } if wsedc.Conn == nil { @@ -232,7 +231,7 @@ func (wsedc *websocketWithEarlyDataConn) WriteBuffer(buffer *buf.Buffer) error { } func (wsedc *websocketWithEarlyDataConn) Read(b []byte) (int, error) { - if wsedc.closed { + if wsedc.ctx.Err() != nil { return 0, io.ErrClosedPipe } if wsedc.Conn == nil { @@ -246,7 +245,6 @@ func (wsedc *websocketWithEarlyDataConn) Read(b []byte) (int, error) { } func (wsedc *websocketWithEarlyDataConn) Close() error { - wsedc.closed = true wsedc.cancel() if wsedc.Conn == nil { // is dialing or not dialed return wsedc.underlay.Close()