From 784c28266cb7c3dda0b4711dd21d4a2921247732 Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Thu, 18 Mar 2021 17:11:10 +0800 Subject: [PATCH] Fix: vmess http broken --- component/vmess/http.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/component/vmess/http.go b/component/vmess/http.go index 92fe3389..5c1a5bd1 100644 --- a/component/vmess/http.go +++ b/component/vmess/http.go @@ -1,6 +1,7 @@ package vmess import ( + "bufio" "bytes" "fmt" "math/rand" @@ -12,7 +13,7 @@ import ( type httpConn struct { net.Conn cfg *HTTPConfig - rhandshake bool + reader *bufio.Reader whandshake bool } @@ -25,8 +26,8 @@ type HTTPConfig struct { // Read implements net.Conn.Read() func (hc *httpConn) Read(b []byte) (int, error) { - if hc.rhandshake { - n, err := hc.Conn.Read(b) + if hc.reader != nil { + n, err := hc.reader.Read(b) return n, err } @@ -40,8 +41,8 @@ func (hc *httpConn) Read(b []byte) (int, error) { return 0, err } - hc.rhandshake = true - return hc.Conn.Read(b) + hc.reader = reader.R + return reader.R.Read(b) } // Write implements io.Writer.