Skip to content

Commit

Permalink
perf: 优化注册逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Oct 30, 2023
1 parent 70302b8 commit c68a326
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
7 changes: 6 additions & 1 deletion client/api/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
19 changes: 4 additions & 15 deletions client/cmd/args/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -20,31 +17,23 @@ 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"),
"region": os.Getenv("NODE_REGION"),
"isp": os.Getenv("NODE_ISP"),
"banner": os.Getenv("NODE_BANNER"),
}

// build Token string

for _, value := range NodeMetaInfo {
Token += value + ";"
}
Token = strings.TrimSuffix(Token, ";")
}

0 comments on commit c68a326

Please sign in to comment.