5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 15:20:30 +00:00

adjust dhtPing response so 'nodes' defaults to an empty list instead of null

This commit is contained in:
Arceliar 2018-11-25 16:16:06 -06:00
parent d520a8a1d5
commit 12e635f946

View File

@ -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)) result, err := a.admin_dhtPing(in["key"].(string), in["coords"].(string), in["target"].(string))
if err == nil { if err == nil {
var infos []map[string]string infos := make([]map[string]string, 0, len(result.Infos))
for _, dinfo := range result.Infos { for _, dinfo := range result.Infos {
info := make(map[string]string) info := map[string]string{
info["key"] = hex.EncodeToString(dinfo.key[:]) "key": hex.EncodeToString(dinfo.key[:]),
info["coords"] = fmt.Sprintf("%v", dinfo.coords) "coords": fmt.Sprintf("%v", dinfo.coords),
}
infos = append(infos, info) infos = append(infos, info)
} }
return admin_info{"nodes": infos}, nil return admin_info{"nodes": infos}, nil