Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

skywire-cli flags for vpn ui and url #1086

Merged
merged 2 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())
Copy link
Member

@jdknives jdknives Feb 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0pcom is the hardcoded localhost IP here an issue for you? Should we pull this from the config directly?

fmt.Println(url)
},
}