diff --git a/CHANGELOG.md b/CHANGELOG.md index eb2d2b4f27..d991c6237e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - added `--disable-apps` flag to `skywire-cli config gen` - added `--disable-auth` and `--enable-auth` flags to `skywire-cli config gen` - added `--best-protocol` flag to `skywire-cli config gen` +- added `skywire-cli visor vpn-ui` and `skywire-cli visor vpn-url` commands ## 0.5.0 ### Changed diff --git a/cmd/skywire-cli/commands/visor/vpn.go b/cmd/skywire-cli/commands/visor/vpn.go new file mode 100644 index 0000000000..b05bb839e4 --- /dev/null +++ b/cmd/skywire-cli/commands/visor/vpn.go @@ -0,0 +1,44 @@ +package visor + +import ( + "fmt" + "log" + + "github.com/spf13/cobra" + "github.com/toqueteos/webbrowser" +) + +func init() { + RootCmd.AddCommand(vpnUICmd) + RootCmd.AddCommand(vpnURLCmd) +} + +var vpnUICmd = &cobra.Command{ + Use: "vpn-ui", + Short: "Open VPN UI on browser", + Run: func(_ *cobra.Command, _ []string) { + client := rpcClient() + overview, err := client.Overview() + if err != nil { + log.Fatal("Failed to connect:", err) + } + url := fmt.Sprintf("http://127.0.0.1:8000/#/vpn/%s/", overview.PubKey.Hex()) + if err := webbrowser.Open(url); err != nil { + log.Fatal("Failed to open VPN UI on browser:", err) + } + }, +} + +var vpnURLCmd = &cobra.Command{ + Use: "vpn-url", + Short: "Show VPN URL address", + Run: func(_ *cobra.Command, _ []string) { + client := rpcClient() + overview, err := client.Overview() + if err != nil { + logger.Fatal("Failed to connect:", err) + } + url := fmt.Sprintf("http://127.0.0.1:8000/#/vpn/%s/", overview.PubKey.Hex()) + fmt.Println(url) + }, +}