Skip to content

Commit

Permalink
Merge pull request #1086 from mrpalide/feature/cli-webui-flags
Browse files Browse the repository at this point in the history
skywire-cli flags for vpn ui and url
  • Loading branch information
jdknives authored Feb 8, 2022
2 parents bf4f0aa + ff89f37 commit 2f797d1
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions cmd/skywire-cli/commands/visor/vpn.go
Original file line number Diff line number Diff line change
@@ -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)
},
}

0 comments on commit 2f797d1

Please sign in to comment.