From 066e6b90e6bba44096d550d2634aeb217c05fe09 Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Fri, 1 Apr 2022 21:41:19 +0800 Subject: [PATCH] fix redirect with wrong target port --- handler/redirect/tcp/handler.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/handler/redirect/tcp/handler.go b/handler/redirect/tcp/handler.go index 2d4cb25..e1b959c 100644 --- a/handler/redirect/tcp/handler.go +++ b/handler/redirect/tcp/handler.go @@ -210,7 +210,11 @@ func (h *redirectHandler) handleHTTPS(ctx context.Context, rw io.ReadWriter, rad if host == "" { host = dstAddr.String() } else { - host = net.JoinHostPort(host, "443") + _, port, _ := net.SplitHostPort(dstAddr.String()) + if port == "" { + port = "443" + } + host = net.JoinHostPort(host, port) } log = log.WithFields(map[string]any{