From 2fbed16d9a8d35bab39a855de5eccc5e3c4ec5c9 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Sun, 12 Apr 2026 11:20:32 +0800 Subject: [PATCH] fix: don't add ":80" to Host for vmess http obfs --- transport/vmess/http.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/transport/vmess/http.go b/transport/vmess/http.go index 77ac2ebeb..e13514681 100644 --- a/transport/vmess/http.go +++ b/transport/vmess/http.go @@ -3,11 +3,10 @@ package vmess import ( "bufio" "bytes" - "fmt" + "io" "net" "net/textproto" - - "github.com/metacubex/mihomo/common/utils" + "net/url" "github.com/metacubex/http" "github.com/metacubex/randv2" @@ -64,10 +63,12 @@ func (hc *httpConn) Write(b []byte) (int, error) { host = header[randv2.IntN(len(header))] } - u := fmt.Sprintf("http://%s%s", net.JoinHostPort(host, "80"), path) - req, err := http.NewRequest(utils.EmptyOr(hc.cfg.Method, http.MethodGet), u, bytes.NewBuffer(b)) - if err != nil { - return 0, err + req := http.Request{ + Method: hc.cfg.Method, // default is GET + Host: host, + URL: &url.URL{Scheme: "http", Host: host, Path: path}, + Header: make(http.Header), + Body: io.NopCloser(bytes.NewReader(b)), } for key, list := range hc.cfg.Headers { req.Header.Set(key, list[randv2.IntN(len(list))])