From 94707dfcdd5b10b30b2989ae13eec460db0a792e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 1 Jul 2024 23:19:42 +0800 Subject: [PATCH] Add name to errors from v2ray HTTP transports --- transport/v2raygrpclite/client.go | 2 +- transport/v2rayhttp/client.go | 2 +- transport/v2rayhttp/conn.go | 2 +- transport/v2rayhttpupgrade/client.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/transport/v2raygrpclite/client.go b/transport/v2raygrpclite/client.go index 588a8133..bd52c1d9 100644 --- a/transport/v2raygrpclite/client.go +++ b/transport/v2raygrpclite/client.go @@ -100,7 +100,7 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) { conn.setup(nil, err) } else if response.StatusCode != 200 { response.Body.Close() - conn.setup(nil, E.New("unexpected status: ", response.Status)) + conn.setup(nil, E.New("v2ray-grpc: unexpected status: ", response.Status)) } else { conn.setup(response.Body, nil) } diff --git a/transport/v2rayhttp/client.go b/transport/v2rayhttp/client.go index 4fa141cc..d817d37d 100644 --- a/transport/v2rayhttp/client.go +++ b/transport/v2rayhttp/client.go @@ -146,7 +146,7 @@ func (c *Client) dialHTTP2(ctx context.Context) (net.Conn, error) { conn.Setup(nil, err) } else if response.StatusCode != 200 { response.Body.Close() - conn.Setup(nil, E.New("unexpected status: ", response.Status)) + conn.Setup(nil, E.New("v2ray-http: unexpected status: ", response.Status)) } else { conn.Setup(response.Body, nil) } diff --git a/transport/v2rayhttp/conn.go b/transport/v2rayhttp/conn.go index 184bc8ae..f7f93f1b 100644 --- a/transport/v2rayhttp/conn.go +++ b/transport/v2rayhttp/conn.go @@ -43,7 +43,7 @@ func (c *HTTPConn) Read(b []byte) (n int, err error) { return 0, E.Cause(err, "read response") } if response.StatusCode != 200 { - return 0, E.New("unexpected status: ", response.Status) + return 0, E.New("v2ray-http: unexpected status: ", response.Status) } if cacheLen := reader.Buffered(); cacheLen > 0 { c.responseCache = buf.NewSize(cacheLen) diff --git a/transport/v2rayhttpupgrade/client.go b/transport/v2rayhttpupgrade/client.go index c10e1b8f..1b72cdfc 100644 --- a/transport/v2rayhttpupgrade/client.go +++ b/transport/v2rayhttpupgrade/client.go @@ -104,7 +104,7 @@ func (c *Client) DialContext(ctx context.Context) (net.Conn, error) { if response.StatusCode != 101 || !strings.EqualFold(response.Header.Get("Connection"), "upgrade") || !strings.EqualFold(response.Header.Get("Upgrade"), "websocket") { - return nil, E.New("unexpected status: ", response.Status) + return nil, E.New("v2ray-http-upgrade: unexpected status: ", response.Status) } if bufReader.Buffered() > 0 { buffer := buf.NewSize(bufReader.Buffered())