diff --git a/handler/redirect/tcp/handler.go b/handler/redirect/tcp/handler.go index 55285c2..a8ebaa6 100644 --- a/handler/redirect/tcp/handler.go +++ b/handler/redirect/tcp/handler.go @@ -210,11 +210,13 @@ func (h *redirectHandler) handleHTTPS(ctx context.Context, rw io.ReadWriter, rad if host == "" { host = dstAddr.String() } else { - _, port, _ := net.SplitHostPort(dstAddr.String()) - if port == "" { - port = "443" + if _, _, err := net.SplitHostPort(host); err != nil { + _, port, _ := net.SplitHostPort(dstAddr.String()) + if port == "" { + port = "443" + } + host = net.JoinHostPort(host, port) } - host = net.JoinHostPort(host, port) } log = log.WithFields(map[string]any{