From 12e635f9464360187c8c6324717c3dbbbe9ced97 Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 25 Nov 2018 16:16:06 -0600 Subject: [PATCH] adjust dhtPing response so 'nodes' defaults to an empty list instead of null --- src/yggdrasil/admin.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index ca3baa2..fa8f8dd 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -308,11 +308,12 @@ func (a *admin) init(c *Core, listenaddr string) { } result, err := a.admin_dhtPing(in["key"].(string), in["coords"].(string), in["target"].(string)) if err == nil { - var infos []map[string]string + infos := make([]map[string]string, 0, len(result.Infos)) for _, dinfo := range result.Infos { - info := make(map[string]string) - info["key"] = hex.EncodeToString(dinfo.key[:]) - info["coords"] = fmt.Sprintf("%v", dinfo.coords) + info := map[string]string{ + "key": hex.EncodeToString(dinfo.key[:]), + "coords": fmt.Sprintf("%v", dinfo.coords), + } infos = append(infos, info) } return admin_info{"nodes": infos}, nil