From ad7e392afe0236ec3d0c3e4353f615129c7515b0 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 6 Mar 2019 17:32:25 +0000 Subject: [PATCH 1/2] Fix getRoutes (#339) --- cmd/yggdrasilctl/main.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/yggdrasilctl/main.go b/cmd/yggdrasilctl/main.go index bbe3cd2e..52800620 100644 --- a/cmd/yggdrasilctl/main.go +++ b/cmd/yggdrasilctl/main.go @@ -388,14 +388,18 @@ func main() { } } case "getroutes": - if _, ok := res["routes"]; !ok { - fmt.Println("No routes found") - } else if res["routes"] == nil { + if routes, ok := res["routes"].(map[string]interface{}); !ok { fmt.Println("No routes found") } else { - fmt.Println("Routes:") - for _, v := range res["routes"].([]interface{}) { - fmt.Println("-", v) + if res["routes"] == nil || len(routes) == 0 { + fmt.Println("No routes found") + } else { + fmt.Println("Routes:") + for k, v := range routes { + if pv, ok := v.(string); ok { + fmt.Println("-", k, " via ", pv) + } + } } } default: From 3bc3002fff885b892b5f7cb13ea63fe7740f578b Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 6 Mar 2019 17:37:48 +0000 Subject: [PATCH 2/2] Add handlers for setTunnelRouting/getTunnelRouting --- cmd/yggdrasilctl/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/yggdrasilctl/main.go b/cmd/yggdrasilctl/main.go index 52800620..b8864dc3 100644 --- a/cmd/yggdrasilctl/main.go +++ b/cmd/yggdrasilctl/main.go @@ -402,6 +402,16 @@ func main() { } } } + case "settunnelrouting": + fallthrough + case "gettunnelrouting": + if enabled, ok := res["enabled"].(bool); !ok { + fmt.Println("Tunnel routing is disabled") + } else if !enabled { + fmt.Println("Tunnel routing is disabled") + } else { + fmt.Println("Tunnel routing is enabled") + } default: if json, err := json.MarshalIndent(recv["response"], "", " "); err == nil { fmt.Println(string(json))