diff --git a/cmd/skywire-cli/commands/vpn/vvpn.go b/cmd/skywire-cli/commands/vpn/vvpn.go index 96dfb15007..bc0db1213f 100644 --- a/cmd/skywire-cli/commands/vpn/vvpn.go +++ b/cmd/skywire-cli/commands/vpn/vvpn.go @@ -5,6 +5,7 @@ import ( "fmt" "strings" "text/tabwriter" + "time" "github.com/spf13/cobra" "github.com/toqueteos/webbrowser" @@ -144,7 +145,32 @@ var vpnStartCmd = &cobra.Command{ var pk cipher.PubKey internal.Catch(cmd.Flags(), pk.Set(args[0])) internal.Catch(cmd.Flags(), clirpc.Client(cmd.Flags()).StartVPNClient(pk)) - internal.PrintOutput(cmd.Flags(), "OK", fmt.Sprintln("OK")) + internal.PrintOutput(cmd.Flags(), "Starting.", "Starting.") + startProcess := true + for startProcess { + time.Sleep(time.Second * 1) + internal.PrintOutput(cmd.Flags(), ".", ".") + states, err := clirpc.Client(cmd.Flags()).Apps() + internal.Catch(cmd.Flags(), err) + + var b bytes.Buffer + w := tabwriter.NewWriter(&b, 0, 0, 5, ' ', tabwriter.TabIndent) + internal.Catch(cmd.Flags(), err) + for _, state := range states { + if state.Name == "vpn-client" { + if state.Status == appserver.AppStatusRunning { + startProcess = false + internal.Catch(cmd.Flags(), w.Flush()) + internal.PrintOutput(cmd.Flags(), "\nRunning!", fmt.Sprintln("\nRunning!")) + } + if state.Status == appserver.AppStatusErrored { + startProcess = false + internal.Catch(cmd.Flags(), w.Flush()) + internal.PrintOutput(cmd.Flags(), "\nError! > "+state.DetailedStatus, fmt.Sprintln("\nError! > "+state.DetailedStatus)) + } + } + } + } }, } diff --git a/dmsghttp-config.json b/dmsghttp-config.json index 5040ea1e7e..86a5e3d388 100644 --- a/dmsghttp-config.json +++ b/dmsghttp-config.json @@ -18,12 +18,6 @@ "server":{ "address":"139.162.45.141:8083" } - }, - { - "static":"02c5c21778c510f9bd29a54565db1ab20b9248804dce3d3fed171ae45a096f4037", - "server":{ - "address":"194.147.142.202:30052" - } } ], "dmsg_discovery": "dmsg://03cd2336e5de74bdab2bbdb44b06b0c8c713a5ee9029615f5526f8c99a6afe87b8:80", @@ -70,12 +64,6 @@ "server":{ "address":"dmsg.server02a4.skywire.skycoin.com:30089" } - }, - { - "static":"02113579604c79b704e169a4fd94fd78167b86fe40da1016f8146935babcc9abcb", - "server":{ - "address":"194.147.142.202:30050" - } } ], "dmsg_discovery": "dmsg://022e607e0914d6e7ccda7587f95790c09e126bbd506cc476a1eda852325aadd1aa:80", diff --git a/pkg/visor/api.go b/pkg/visor/api.go index 3e5cfa8df5..8146bd4459 100644 --- a/pkg/visor/api.go +++ b/pkg/visor/api.go @@ -661,7 +661,7 @@ func (v *Visor) VPNServers(version, country string) ([]servicedisc.Service, erro PK: v.conf.PK, SK: v.conf.SK, DiscAddr: v.conf.Launcher.ServiceDisc, - }, &http.Client{Timeout: time.Duration(1) * time.Second}, "") + }, &http.Client{Timeout: time.Duration(20) * time.Second}, "") vpnServers, err := sdClient.Services(context.Background(), 0, version, country) if err != nil { v.log.Error("Error getting public vpn servers: ", err) diff --git a/pkg/visor/init.go b/pkg/visor/init.go index 2e240b7c6f..38a8e0b554 100644 --- a/pkg/visor/init.go +++ b/pkg/visor/init.go @@ -555,6 +555,7 @@ func initTransportSetup(ctx context.Context, v *Visor, log *logging.Logger) erro return nil } +// getRouteSetupHooks aka autotransport func getRouteSetupHooks(ctx context.Context, v *Visor, log *logging.Logger) []router.RouteSetupHook { retrier := netutil.NewRetrier(log, time.Second, time.Second*20, 3, 1.3) return []router.RouteSetupHook{ @@ -575,6 +576,9 @@ func getRouteSetupHooks(ctx context.Context, v *Visor, log *logging.Logger) []ro dmsgFallback := func() error { return retrier.Do(ctx, func() error { _, err := tm.SaveTransport(ctx, rPK, network.DMSG, transport.LabelAutomatic) + if err != nil { + log.Debugf("Establishing automatic DMSG transport failed.") + } return err }) } @@ -589,10 +593,6 @@ func getRouteSetupHooks(ctx context.Context, v *Visor, log *logging.Logger) []ro log.WithField("pk", rPK.String()).Warn("pk not found in the transports") // check if automatic transport is available, if it does, // continue with route creation - if v.conf.Transport.PublicAutoconnect { - // we return nil here, router will use multi-hop STCPR rather than one hop DMSG - return nil - } return dmsgFallback() } // try to establish direct connection to rPK (single hop) using SUDPH or STCPR @@ -623,7 +623,10 @@ func getRouteSetupHooks(ctx context.Context, v *Visor, log *logging.Logger) []ro _, err := tm.SaveTransport(ctx, rPK, network.STCPR, transport.LabelAutomatic) return err }) - return err + if err == nil { + return nil + } + log.Debugf("Establishing automatic STCPR transport failed.") } // trying to establish direct connection to rPK using SUDPH if trySUDPH { @@ -631,7 +634,10 @@ func getRouteSetupHooks(ctx context.Context, v *Visor, log *logging.Logger) []ro _, err := tm.SaveTransport(ctx, rPK, network.SUDPH, transport.LabelAutomatic) return err }) - return err + if err == nil { + return nil + } + log.Debugf("Establishing automatic SUDPH transport failed.") } return dmsgFallback()