diff --git a/src/yggdrasil/admin.go b/src/yggdrasil/admin.go index 00625e14..2aee240b 100644 --- a/src/yggdrasil/admin.go +++ b/src/yggdrasil/admin.go @@ -308,13 +308,14 @@ 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 { - infos := make([]map[string]string, 0, len(result.Infos)) + infos := make(map[string]map[string]string, len(result.Infos)) for _, dinfo := range result.Infos { info := map[string]string{ "key": hex.EncodeToString(dinfo.key[:]), "coords": fmt.Sprintf("%v", dinfo.coords), } - infos = append(infos, info) + addr := net.IP(address_addrForNodeID(getNodeID(&dinfo.key))[:]).String() + infos[addr] = info } return admin_info{"nodes": infos}, nil } else { diff --git a/yggdrasilctl.go b/yggdrasilctl.go index 4a76361f..b3b1cef0 100644 --- a/yggdrasilctl.go +++ b/yggdrasilctl.go @@ -107,7 +107,7 @@ func main() { switch strings.ToLower(req["request"].(string)) { case "dot": fmt.Println(res["dot"]) - case "help", "getpeers", "getswitchpeers", "getdht", "getsessions": + case "help", "getpeers", "getswitchpeers", "getdht", "getsessions", "dhtping": maxWidths := make(map[string]int) var keyOrder []string keysOrdered := false @@ -296,17 +296,6 @@ func main() { fmt.Println("-", v) } } - case "dhtping": - if _, ok := res["nodes"]; !ok { - fmt.Println("No nodes found") - } else if res["nodes"] == nil { - fmt.Println("No nodes found") - } else { - for _, v := range res["nodes"].([]interface{}) { - m := v.(map[string]interface{}) - fmt.Println("-", m["key"], m["coords"]) - } - } default: if json, err := json.MarshalIndent(recv["response"], "", " "); err == nil { fmt.Println(string(json))