mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 12:42:27 +08:00
fix: ipv6 http host addr
This commit is contained in:
parent
6399347a63
commit
9e7eaf720f
@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/netip"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,6 +49,11 @@ func removeExtraHTTPHostPort(req *http.Request) {
|
|||||||
|
|
||||||
if pHost, port, err := net.SplitHostPort(host); err == nil && (port == "80" || port == "443") {
|
if pHost, port, err := net.SplitHostPort(host); err == nil && (port == "80" || port == "443") {
|
||||||
host = pHost
|
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
|
req.Host = host
|
||||||
|
Loading…
Reference in New Issue
Block a user