From 02f98a2592290ad4eb17a7bee14cb77400316f3c Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 8 Dec 2018 11:01:05 +0000 Subject: [PATCH] Only show build name and version if it is known --- cmd/yggdrasilctl/main.go | 4 ++-- src/yggdrasil/admin.go | 9 +++++++-- src/yggdrasil/core.go | 8 ++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cmd/yggdrasilctl/main.go b/cmd/yggdrasilctl/main.go index ca3078b1..dcbde87a 100644 --- a/cmd/yggdrasilctl/main.go +++ b/cmd/yggdrasilctl/main.go @@ -183,10 +183,10 @@ func main() { } case "getself": for k, v := range res["self"].(map[string]interface{}) { - if buildname, ok := v.(map[string]interface{})["build_name"].(string); ok { + if buildname, ok := v.(map[string]interface{})["build_name"].(string); ok && buildname != "unknown" { fmt.Println("Build name:", buildname) } - if buildversion, ok := v.(map[string]interface{})["build_version"].(string); ok { + if buildversion, ok := v.(map[string]interface{})["build_version"].(string); ok && buildversion != "unknown" { fmt.Println("Build version:", buildversion) } fmt.Println("IPv6 address:", k) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 7d82b135..2c65b6a8 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -556,13 +556,18 @@ func (a *admin) getData_getSelf() *admin_nodeInfo { table := a.core.switchTable.table.Load().(lookupTable) coords := table.self.getCoords() self := admin_nodeInfo{ - {"build_name", GetBuildName()}, - {"build_version", GetBuildVersion()}, {"box_pub_key", hex.EncodeToString(a.core.boxPub[:])}, {"ip", a.core.GetAddress().String()}, {"subnet", a.core.GetSubnet().String()}, {"coords", fmt.Sprint(coords)}, } + if name := GetBuildName(); name != "unknown" { + self = append(self, admin_pair{"build_name", name}) + } + if version := GetBuildVersion(); version != "unknown" { + self = append(self, admin_pair{"build_version", version}) + } + return &self } diff --git a/src/yggdrasil/core.go b/src/yggdrasil/core.go index 682d815e..5ab91a74 100644 --- a/src/yggdrasil/core.go +++ b/src/yggdrasil/core.go @@ -87,11 +87,11 @@ func GetBuildVersion() string { func (c *Core) Start(nc *config.NodeConfig, log *log.Logger) error { c.log = log - if buildName != "" { - c.log.Println("Build name:", buildName) + if name := GetBuildName(); name != "unknown" { + c.log.Println("Build name:", name) } - if buildVersion != "" { - c.log.Println("Build version:", buildVersion) + if version := GetBuildVersion(); version != "unknown" { + c.log.Println("Build version:", version) } c.log.Println("Starting up...")