add hpeer for non-node peers

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
This commit is contained in:
Evan Hazlett 2019-10-07 10:06:12 -04:00
parent 9b07492180
commit 332378e3ff
No known key found for this signature in database
GPG key ID: A519480096146526
20 changed files with 1348 additions and 195 deletions

View file

@ -34,8 +34,12 @@ var peersCommand = cli.Command{
Usage: "peer management",
Subcommands: []cli.Command{
listPeersCommand,
authorizedPeersCommand,
authorizePeerCommand,
deauthorizePeerCommand,
},
}
var listPeersCommand = cli.Command{
Name: "list",
Usage: "list peers",
@ -61,3 +65,57 @@ var listPeersCommand = cli.Command{
return nil
},
}
var authorizedPeersCommand = cli.Command{
Name: "authorized",
Usage: "authorized peers in the cluster",
Action: func(cx *cli.Context) error {
c, err := getClient(cx)
if err != nil {
return err
}
defer c.Close()
ids, err := c.AuthorizedPeers()
if err != nil {
return err
}
w := tabwriter.NewWriter(os.Stdout, 20, 1, 3, ' ', 0)
fmt.Fprintf(w, "ID\n")
for _, id := range ids {
fmt.Fprintf(w, "%s\n", id)
}
w.Flush()
return nil
},
}
var authorizePeerCommand = cli.Command{
Name: "authorize",
Usage: "authorize peer to cluster",
Action: func(cx *cli.Context) error {
c, err := getClient(cx)
if err != nil {
return err
}
defer c.Close()
id := cx.Args().First()
return c.AuthorizePeer(id)
},
}
var deauthorizePeerCommand = cli.Command{
Name: "deauthorize",
Usage: "deauthorize peer from cluster",
Action: func(cx *cli.Context) error {
c, err := getClient(cx)
if err != nil {
return err
}
defer c.Close()
id := cx.Args().First()
return c.DeauthorizePeer(id)
},
}