fix: normalize host:port for CONNECT to handle IPv6 addresses
This commit is contained in:
parent
9a0ab6b5dd
commit
07e2c4ee36
1 changed files with 8 additions and 0 deletions
|
|
@ -66,6 +66,14 @@ func (p *Proxy) handleConnect(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
host, port, err := net.SplitHostPort(target)
|
||||
if err != nil {
|
||||
host = target
|
||||
target = net.JoinHostPort(host, "443")
|
||||
} else {
|
||||
target = net.JoinHostPort(host, port)
|
||||
}
|
||||
|
||||
dest, err := net.DialTimeout("tcp", target, 10*time.Second)
|
||||
if err != nil {
|
||||
p.logger.Warn("connect to %s failed: %v", target, err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue