From bbbc09fb118e1fbbb34fc62f5aafb4e7852ab7ef Mon Sep 17 00:00:00 2001 From: Mads Jensen Date: Sun, 15 Feb 2026 16:53:17 +0100 Subject: [PATCH] proxy/utils: Use net.JoinHostPort to format address. --- pkg/proxy/util/utils.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/proxy/util/utils.go b/pkg/proxy/util/utils.go index 59d85a54d62..b55efd8eea2 100644 --- a/pkg/proxy/util/utils.go +++ b/pkg/proxy/util/utils.go @@ -19,6 +19,7 @@ package util import ( "fmt" "net" + "strconv" "strings" "time" @@ -169,10 +170,7 @@ func AppendPortIfNeeded(addr string, port int32) string { } // Append port to address. - if ip.To4() != nil { - return fmt.Sprintf("%s:%d", addr, port) - } - return fmt.Sprintf("[%s]:%d", addr, port) + return net.JoinHostPort(addr, strconv.Itoa(int(port))) } // EnsureSysctl sets a kernel sysctl to a given numeric value.