cli: net reachability command

This commit is contained in:
Łukasz Magiera
2020-08-13 13:18:14 +02:00
parent f212ca60c8
commit 3f2a62b5e2
4 changed files with 58 additions and 0 deletions
+26
View File
@@ -24,6 +24,7 @@ var netCmd = &cli.Command{
NetId,
netFindPeer,
netScores,
netReachability,
},
}
@@ -202,3 +203,28 @@ var netFindPeer = &cli.Command{
return nil
},
}
var netReachability = &cli.Command{
Name: "reachability",
Usage: "Print information about reachability from the internet",
Action: func(cctx *cli.Context) error {
api, closer, err := GetAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := ReqContext(cctx)
i, err := api.NetAutoNatStatus(ctx)
if err != nil {
return err
}
fmt.Println("AutoNAT status: ", i.Reachability.String())
if i.PublicAddr != nil {
fmt.Println("Public address: ", i.PublicAddr.String())
}
return nil
},
}