From c68a3264edd96185cd636e7751f8c6a11941b7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=A5=E6=B5=B7?= Date: Mon, 30 Oct 2023 14:16:34 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/api/join.go | 7 ++++++- client/cmd/args/main.go | 19 ++++--------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/client/api/join.go b/client/api/join.go index 099aafd..2e63bc4 100644 --- a/client/api/join.go +++ b/client/api/join.go @@ -8,7 +8,12 @@ import ( ) func Join() error { - body, err := httpPost("/api/join", args.VersionNumber+";"+args.Token) + token := args.VersionNumber + for _, value := range args.NodeMetaInfo { + token += ";" + value + } + + body, err := httpPost("/api/join", token) if err != nil { return err } diff --git a/client/cmd/args/main.go b/client/cmd/args/main.go index 110c289..96b4e95 100644 --- a/client/cmd/args/main.go +++ b/client/cmd/args/main.go @@ -2,13 +2,10 @@ package args import ( "os" - "strings" "github.com/opentdp/go-helper/logman" ) -var Token string - var Version = "0.2.0" var VersionNumber = "2" @@ -20,19 +17,18 @@ var NodeMetaInfo map[string]string var MetaServerListen = "127.0.0.1:9000" func init() { + var err error + // get EtcDirectory EtcDirectory = os.TempDir() // get ExecutablePath - - if path, err := os.Executable(); err != nil { + ExecutablePath, err = os.Executable() + if err != nil { logman.Fatal("Find executable failed", "msg", err) - } else { - ExecutablePath = path } // get NodeMetaInfo - NodeMetaInfo = map[string]string{ "name": os.Getenv("NODE_NAME"), "owner": os.Getenv("NODE_OWNER"), @@ -40,11 +36,4 @@ func init() { "isp": os.Getenv("NODE_ISP"), "banner": os.Getenv("NODE_BANNER"), } - - // build Token string - - for _, value := range NodeMetaInfo { - Token += value + ";" - } - Token = strings.TrimSuffix(Token, ";") }