From f09f754b1c58eeba764d715f1197f626ac712bb3 Mon Sep 17 00:00:00 2001 From: fengxsong Date: Mon, 9 Oct 2023 10:35:26 +0800 Subject: [PATCH] fix: if string addr has not colon (#4045) Signed-off-by: fengxsong --- pkg/exec/exec.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/exec/exec.go b/pkg/exec/exec.go index cc8a8287e61..66ec4c7b1ad 100644 --- a/pkg/exec/exec.go +++ b/pkg/exec/exec.go @@ -28,6 +28,7 @@ import ( "github.com/labring/sealos/pkg/ssh" "github.com/labring/sealos/pkg/unshare" fileutil "github.com/labring/sealos/pkg/utils/file" + "github.com/labring/sealos/pkg/utils/iputils" "github.com/labring/sealos/pkg/utils/logger" netutil "github.com/labring/sealos/pkg/utils/net" ) @@ -138,10 +139,7 @@ func (w *wrap) isLocal(addr string) bool { if unshare.IsRootless() { return false } - host, _, err := net.SplitHostPort(addr) - if err != nil { - return false - } + host := iputils.GetHostIP(addr) if host == "localhost" || host == "127.0.0.1" || w.localAddresses.Has(host) { return true }