mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 01:33:49 +08:00
fix: ipv6 http host addr
This commit is contained in:
parent
6399347a63
commit
9e7eaf720f
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -48,6 +49,11 @@ func removeExtraHTTPHostPort(req *http.Request) {
|
||||
|
||||
if pHost, port, err := net.SplitHostPort(host); err == nil && (port == "80" || port == "443") {
|
||||
host = pHost
|
||||
if ip, err := netip.ParseAddr(pHost); err == nil && ip.Is6() {
|
||||
// RFC 2617 Sec 3.2.2, for IPv6 literal
|
||||
// addresses the Host header needs to follow the RFC 2732 grammar for "host"
|
||||
host = "[" + host + "]"
|
||||
}
|
||||
}
|
||||
|
||||
req.Host = host
|
||||
|
Loading…
Reference in New Issue
Block a user