mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
Fix sending arguments to the admin socket in yggdrasilctl
This commit is contained in:
parent
1de587a971
commit
c922eba2d8
3 changed files with 28 additions and 21 deletions
|
@ -85,7 +85,7 @@ func run() int {
|
|||
encoder := json.NewEncoder(conn)
|
||||
send := &admin.AdminSocketRequest{}
|
||||
recv := &admin.AdminSocketResponse{}
|
||||
|
||||
args := map[string]string{}
|
||||
for c, a := range cmdLineEnv.args {
|
||||
if c == 0 {
|
||||
if strings.HasPrefix(a, "-") {
|
||||
|
@ -96,15 +96,17 @@ func run() int {
|
|||
send.Name = a
|
||||
continue
|
||||
}
|
||||
tokens := strings.SplitN(a, "=", 1)
|
||||
tokens := strings.SplitN(a, "=", 2)
|
||||
switch {
|
||||
case len(tokens) == 1:
|
||||
panic("incomplete argument supplied")
|
||||
logger.Println("Ignoring invalid argument:", a)
|
||||
default:
|
||||
send.Arguments[tokens[0]] = tokens[1]
|
||||
args[tokens[0]] = tokens[1]
|
||||
}
|
||||
}
|
||||
|
||||
if send.Arguments, err = json.Marshal(args); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := encoder.Encode(&send); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -139,7 +141,7 @@ func run() int {
|
|||
table.SetNoWhiteSpace(true)
|
||||
table.SetAutoWrapText(false)
|
||||
|
||||
switch strings.ToLower(recv.Request.Name) {
|
||||
switch strings.ToLower(send.Name) {
|
||||
case "list":
|
||||
var resp admin.ListResponse
|
||||
if err := json.Unmarshal(recv.Response, &resp); err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue