fix: url format error when host is IPv6

[Bug] 使用IPV6地址+vmess+http伪装的配置引起内核panic MetaCubeX/mihomo#1063
This commit is contained in:
Skyxim 2024-02-26 06:05:06 +00:00
parent 78b4b11f26
commit 0619c75276

View file

@ -60,7 +60,7 @@ func (hc *httpConn) Write(b []byte) (int, error) {
host = header[fastrand.Intn(len(header))]
}
u := fmt.Sprintf("http://%s%s", host, path)
u := fmt.Sprintf("http://%s%s", net.JoinHostPort(host, "80"), path)
req, _ := http.NewRequest(utils.EmptyOr(hc.cfg.Method, http.MethodGet), u, bytes.NewBuffer(b))
for key, list := range hc.cfg.Headers {
req.Header.Set(key, list[fastrand.Intn(len(list))])