forked from bazil/bazil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
set.go
42 lines (37 loc) · 813 Bytes
/
set.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package set
import (
clibazil "bazil.org/bazil/cli"
"bazil.org/bazil/cliutil/subcommands"
"bazil.org/bazil/peer"
"bazil.org/bazil/server/control/wire"
"golang.org/x/net/context"
)
type setCommand struct {
subcommands.Description
Arguments struct {
PubKey peer.PublicKey
Addr string `positional:"metavar=HOST:PORT"`
}
}
func (cmd *setCommand) Run() error {
req := &wire.PeerLocationSetRequest{
Pub: cmd.Arguments.PubKey[:],
Netloc: cmd.Arguments.Addr,
}
ctx := context.Background()
client, err := clibazil.Bazil.Control()
if err != nil {
return err
}
if _, err := client.PeerLocationSet(ctx, req); err != nil {
// TODO unwrap error
return err
}
return nil
}
var set = setCommand{
Description: "set network location for peer",
}
func init() {
subcommands.Register(&set)
}