Fix: vmess http should use Host header on request

This commit is contained in:
gVisor bot 2021-05-16 20:05:41 +08:00
parent 3b0183ef1b
commit aaaef92fbf

View File

@ -52,7 +52,12 @@ func (hc *httpConn) Write(b []byte) (int, error) {
} }
path := hc.cfg.Path[rand.Intn(len(hc.cfg.Path))] 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)) req, _ := http.NewRequest("GET", u, bytes.NewBuffer(b))
for key, list := range hc.cfg.Headers { for key, list := range hc.cfg.Headers {
req.Header.Set(key, list[rand.Intn(len(list))]) req.Header.Set(key, list[rand.Intn(len(list))])