Fix IPv6 literal host handling

This commit is contained in:
世界
2026-10-23 19:57:05 +08:00
parent 9c24112d12
commit 42f487bd0d
6 changed files with 45 additions and 30 deletions
+7 -10
View File
@@ -5,10 +5,8 @@ import (
"context"
"errors"
"io"
"net"
"net/http"
"net/url"
"strconv"
"sync"
"sync/atomic"
"time"
@@ -82,15 +80,14 @@ func NewHTTPS(ctx context.Context, logger log.ContextLogger, tag string, options
host = options.Server
}
}
destinationURL := url.URL{
Scheme: "https",
Host: host,
}
if destinationURL.Host == "" {
destinationURL.Host = options.Server
}
destinationAddress := M.ParseSocksaddrHostPort(host, options.ServerPort)
destinationURL := url.URL{Scheme: "https"}
if options.ServerPort != 0 && options.ServerPort != 443 {
destinationURL.Host = net.JoinHostPort(destinationURL.Host, strconv.Itoa(int(options.ServerPort)))
destinationURL.Host = destinationAddress.String()
} else if destinationAddress.IsIPv6() {
destinationURL.Host = "[" + destinationAddress.AddrString() + "]"
} else {
destinationURL.Host = destinationAddress.AddrString()
}
path := options.Path
if path == "" {