-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1086 from mrpalide/feature/cli-webui-flags
skywire-cli flags for vpn ui and url
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}, | ||
} |