From d2cbad777ae00a444e193a18a3cbbc00a7317d33 Mon Sep 17 00:00:00 2001 From: blackdobb <64015779+blackdobb@users.noreply.github.com> Date: Fri, 20 Aug 2021 16:19:38 +0800 Subject: add the validation of hostname due to the problem caused by long name (#3044) Signed-off-by: blackdobb --- cloud/cmd/cloudcore/app/server.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'cloud/cmd') diff --git a/cloud/cmd/cloudcore/app/server.go b/cloud/cmd/cloudcore/app/server.go index ae41ba604..7d1890eca 100644 --- a/cloud/cmd/cloudcore/app/server.go +++ b/cloud/cmd/cloudcore/app/server.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "math/rand" - "os" "time" "github.com/spf13/cobra" @@ -145,7 +144,8 @@ func NegotiateTunnelPort() (*int, error) { return nil, err } - localIP := getLocalIP() + hostnameOverride := util.GetHostname() + localIP, _ := util.GetLocalIP(hostnameOverride) var record iptables.TunnelPortRecord if err == nil { @@ -227,12 +227,3 @@ func negotiatePort(portRecord map[int]bool) int { } } } - -func getLocalIP() string { - hostnameOverride, err := os.Hostname() - if err != nil { - hostnameOverride = constants.DefaultHostnameOverride - } - localIP, _ := util.GetLocalIP(hostnameOverride) - return localIP -} -- cgit v1.2.3