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

Merge pull request #369 from neilalexander/fix339

Fix getRoutes
This commit is contained in:
Neil Alexander 2019-03-06 17:40:21 +00:00 committed by GitHub
commit 898f7865b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -388,16 +388,30 @@ func main() {
}
}
case "getroutes":
if _, ok := res["routes"]; !ok {
if routes, ok := res["routes"].(map[string]interface{}); !ok {
fmt.Println("No routes found")
} else if res["routes"] == nil {
} else {
if res["routes"] == nil || len(routes) == 0 {
fmt.Println("No routes found")
} else {
fmt.Println("Routes:")
for _, v := range res["routes"].([]interface{}) {
fmt.Println("-", v)
for k, v := range routes {
if pv, ok := v.(string); ok {
fmt.Println("-", k, " via ", pv)
}
}
}
}
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))