From 06fdd3abe0ab610a57ce88c448e59003d3c13368 Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Sun, 16 May 2021 20:05:41 +0800 Subject: [PATCH] Fix: vmess http should use Host header on request --- transport/vmess/http.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/transport/vmess/http.go b/transport/vmess/http.go index 5c1a5bd1..1c09e215 100644 --- a/transport/vmess/http.go +++ b/transport/vmess/http.go @@ -52,7 +52,12 @@ func (hc *httpConn) Write(b []byte) (int, error) { } path := hc.cfg.Path[rand.Intn(len(hc.cfg.Path))] - u := fmt.Sprintf("http://%s%s", hc.cfg.Host, path) + host := hc.cfg.Host + if header := hc.cfg.Headers["Host"]; len(header) != 0 { + host = header[rand.Intn(len(header))] + } + + u := fmt.Sprintf("http://%s%s", host, path) req, _ := http.NewRequest("GET", u, bytes.NewBuffer(b)) for key, list := range hc.cfg.Headers { req.Header.Set(key, list[rand.Intn(len(list))])