mirror of https://github.com/status-im/consul.git
command: fix panic when client RPC is asked for a keyring operation
This commit is contained in:
parent
9d01174521
commit
91ad3461f4
|
@ -655,6 +655,10 @@ func (i *AgentRPC) handleKeyring(client *rpcClient, seq uint64, cmd string) erro
|
||||||
Error: errToString(err),
|
Error: errToString(err),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if queryResp == nil {
|
||||||
|
goto SEND
|
||||||
|
}
|
||||||
|
|
||||||
for _, kr := range queryResp.Responses {
|
for _, kr := range queryResp.Responses {
|
||||||
var pool string
|
var pool string
|
||||||
if kr.WAN {
|
if kr.WAN {
|
||||||
|
@ -689,6 +693,7 @@ func (i *AgentRPC) handleKeyring(client *rpcClient, seq uint64, cmd string) erro
|
||||||
r.Info = append(r.Info, info)
|
r.Info = append(r.Info, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SEND:
|
||||||
return client.Send(&header, r)
|
return client.Send(&header, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,20 +96,6 @@ func (c *KeyringCommand) Run(args []string) int {
|
||||||
}
|
}
|
||||||
defer client.Close()
|
defer client.Close()
|
||||||
|
|
||||||
// For all key-related operations, we must be querying a server node. It is
|
|
||||||
// probably better to enforce this even for LAN pool changes, because other-
|
|
||||||
// wise, the same exact command syntax will have different results depending
|
|
||||||
// on where it was run.
|
|
||||||
s, err := client.Stats()
|
|
||||||
if err != nil {
|
|
||||||
c.Ui.Error(fmt.Sprintf("Error: %s", err))
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
if s["consul"]["server"] != "true" {
|
|
||||||
c.Ui.Error("Error: Key modification can only be handled by a server")
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if listKeys {
|
if listKeys {
|
||||||
c.Ui.Info("Asking all members for installed keys...")
|
c.Ui.Info("Asking all members for installed keys...")
|
||||||
r, err := client.ListKeys()
|
r, err := client.ListKeys()
|
||||||
|
|
Loading…
Reference in New Issue