Fix sending arguments to the admin socket in yggdrasilctl

This commit is contained in:
Neil Alexander 2022-09-24 21:28:09 +01:00
parent 1de587a971
commit c922eba2d8
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 28 additions and 21 deletions

View file

@ -4,6 +4,7 @@ import (
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"runtime"
"strings"
"time"
@ -160,11 +161,14 @@ func (m *nodeinfo) nodeInfoAdminHandler(in json.RawMessage) (interface{}, error)
if err := json.Unmarshal(in, &req); err != nil {
return nil, err
}
if req.Key == "" {
return nil, fmt.Errorf("No remote public key supplied")
}
var key keyArray
var kbs []byte
var err error
if kbs, err = hex.DecodeString(req.Key); err != nil {
return nil, err
return nil, fmt.Errorf("Failed to decode public key: %w", err)
}
copy(key[:], kbs)
ch := make(chan []byte, 1)
@ -175,7 +179,7 @@ func (m *nodeinfo) nodeInfoAdminHandler(in json.RawMessage) (interface{}, error)
defer timer.Stop()
select {
case <-timer.C:
return nil, errors.New("timeout")
return nil, errors.New("Timed out waiting for response")
case info := <-ch:
var msg json.RawMessage
if err := msg.UnmarshalJSON(info); err != nil {