mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-10 02:50:27 +00:00
Make yggdrasilctl less case-sensitive
This commit is contained in:
parent
5cff8428c3
commit
cff7ef026f
@ -309,7 +309,7 @@ func (a *admin) handleRequest(conn net.Conn) {
|
|||||||
handlers:
|
handlers:
|
||||||
for _, handler := range a.handlers {
|
for _, handler := range a.handlers {
|
||||||
// We've found the handler that matches the request
|
// We've found the handler that matches the request
|
||||||
if recv["request"] == handler.name {
|
if strings.ToLower(recv["request"].(string)) == strings.ToLower(handler.name) {
|
||||||
// Check that we have all the required arguments
|
// Check that we have all the required arguments
|
||||||
for _, arg := range handler.args {
|
for _, arg := range handler.args {
|
||||||
// An argument in [square brackets] is optional and not required,
|
// An argument in [square brackets] is optional and not required,
|
||||||
|
@ -63,7 +63,7 @@ func main() {
|
|||||||
if i, err := strconv.Atoi(tokens[1]); err == nil {
|
if i, err := strconv.Atoi(tokens[1]); err == nil {
|
||||||
send[tokens[0]] = i
|
send[tokens[0]] = i
|
||||||
} else {
|
} else {
|
||||||
switch tokens[1] {
|
switch strings.ToLower(tokens[1]) {
|
||||||
case "true":
|
case "true":
|
||||||
send[tokens[0]] = true
|
send[tokens[0]] = true
|
||||||
case "false":
|
case "false":
|
||||||
@ -104,10 +104,10 @@ func main() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch req["request"] {
|
switch strings.ToLower(req["request"].(string)) {
|
||||||
case "dot":
|
case "dot":
|
||||||
fmt.Println(res["dot"])
|
fmt.Println(res["dot"])
|
||||||
case "help", "getPeers", "getSwitchPeers", "getDHT", "getSessions":
|
case "help", "getpeers", "getswitchpeers", "getdht", "getsessions":
|
||||||
maxWidths := make(map[string]int)
|
maxWidths := make(map[string]int)
|
||||||
var keyOrder []string
|
var keyOrder []string
|
||||||
keysOrdered := false
|
keysOrdered := false
|
||||||
@ -163,7 +163,7 @@ func main() {
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "getTunTap", "setTunTap":
|
case "gettuntap", "settuntap":
|
||||||
for k, v := range res {
|
for k, v := range res {
|
||||||
fmt.Println("Interface name:", k)
|
fmt.Println("Interface name:", k)
|
||||||
if mtu, ok := v.(map[string]interface{})["mtu"].(float64); ok {
|
if mtu, ok := v.(map[string]interface{})["mtu"].(float64); ok {
|
||||||
@ -173,7 +173,7 @@ func main() {
|
|||||||
fmt.Println("TAP mode:", tap_mode)
|
fmt.Println("TAP mode:", tap_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "getSelf":
|
case "getself":
|
||||||
for k, v := range res["self"].(map[string]interface{}) {
|
for k, v := range res["self"].(map[string]interface{}) {
|
||||||
fmt.Println("IPv6 address:", k)
|
fmt.Println("IPv6 address:", k)
|
||||||
if subnet, ok := v.(map[string]interface{})["subnet"].(string); ok {
|
if subnet, ok := v.(map[string]interface{})["subnet"].(string); ok {
|
||||||
@ -183,7 +183,7 @@ func main() {
|
|||||||
fmt.Println("Coords:", coords)
|
fmt.Println("Coords:", coords)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "addPeer", "removePeer", "addAllowedEncryptionPublicKey", "removeAllowedEncryptionPublicKey":
|
case "addpeer", "removepeer", "addallowedencryptionpublickey", "removeallowedencryptionpublickey":
|
||||||
if _, ok := res["added"]; ok {
|
if _, ok := res["added"]; ok {
|
||||||
for _, v := range res["added"].([]interface{}) {
|
for _, v := range res["added"].([]interface{}) {
|
||||||
fmt.Println("Added:", fmt.Sprint(v))
|
fmt.Println("Added:", fmt.Sprint(v))
|
||||||
@ -204,7 +204,7 @@ func main() {
|
|||||||
fmt.Println("Not removed:", fmt.Sprint(v))
|
fmt.Println("Not removed:", fmt.Sprint(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "getAllowedEncryptionPublicKeys":
|
case "getallowedencryptionpublickeys":
|
||||||
if _, ok := res["allowed_box_pubs"]; !ok {
|
if _, ok := res["allowed_box_pubs"]; !ok {
|
||||||
fmt.Println("All connections are allowed")
|
fmt.Println("All connections are allowed")
|
||||||
} else if res["allowed_box_pubs"] == nil {
|
} else if res["allowed_box_pubs"] == nil {
|
||||||
@ -215,7 +215,7 @@ func main() {
|
|||||||
fmt.Println("-", v)
|
fmt.Println("-", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "getMulticastInterfaces":
|
case "getmulticastinterfaces":
|
||||||
if _, ok := res["multicast_interfaces"]; !ok {
|
if _, ok := res["multicast_interfaces"]; !ok {
|
||||||
fmt.Println("No multicast interfaces found")
|
fmt.Println("No multicast interfaces found")
|
||||||
} else if res["multicast_interfaces"] == nil {
|
} else if res["multicast_interfaces"] == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user