Skip to content

Commit

Permalink
Merge pull request #1393 from mrpalide/feature/vpn-ip-printing-on-cli…
Browse files Browse the repository at this point in the history
…-connection-established-message

Printing new IP after connecting to VPN in CLI
  • Loading branch information
ersonp authored Oct 20, 2022
2 parents ddccd7f + 578647a commit 1599b75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions cmd/skywire-cli/commands/vpn/vvpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
clirpc "github.com/skycoin/skywire/cmd/skywire-cli/commands/rpc"
"github.com/skycoin/skywire/cmd/skywire-cli/internal"
"github.com/skycoin/skywire/pkg/app/appserver"
"github.com/skycoin/skywire/pkg/visor"
"github.com/skycoin/skywire/pkg/visor/visorconfig"
)

Expand Down Expand Up @@ -162,6 +163,10 @@ var vpnStartCmd = &cobra.Command{
startProcess = false
internal.Catch(cmd.Flags(), w.Flush())
internal.PrintOutput(cmd.Flags(), "\nRunning!", fmt.Sprintln("\nRunning!"))
ip, err := visor.GetIP()
if err == nil {
internal.PrintOutput(cmd.Flags(), fmt.Sprintf("\nYour current IP: %s", ip), fmt.Sprintf("Your current IP: %s\n", ip))
}
}
if state.Status == appserver.AppStatusErrored {
startProcess = false
Expand Down
5 changes: 3 additions & 2 deletions pkg/visor/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ func getPublicIP(v *Visor, service string) (string, error) {
return pIP, fmt.Errorf("provided URL is invalid: %w", err)
}

pIP, err = getIP()
pIP, err = GetIP()
if err != nil {
<-v.stunReady
if v.stunClient.PublicIP != nil {
Expand All @@ -1313,7 +1313,8 @@ type ipAPI struct {
PublicIP string `json:"ip_address"`
}

func getIP() (string, error) {
// GetIP used for getting current IP of visor
func GetIP() (string, error) {
req, err := http.Get("http://ip.skycoin.com")
if err != nil {
return "", err
Expand Down

0 comments on commit 1599b75

Please sign in to comment.