Skip to content

Commit

Permalink
revert deleted function
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpalide committed Jan 29, 2022
1 parent 09a62c8 commit e264ec5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
23 changes: 23 additions & 0 deletions internal/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package gui

import (
"context"
"embed"
"fmt"
"io"
Expand All @@ -19,6 +20,7 @@ import (
"github.com/skycoin/skycoin/src/util/logging"
"github.com/toqueteos/webbrowser"

"github.com/skycoin/skywire/pkg/servicedisc"
"github.com/skycoin/skywire/pkg/skyenv"
"github.com/skycoin/skywire/pkg/visor/visorconfig"
)
Expand Down Expand Up @@ -190,6 +192,27 @@ func handleVPNLinkButton(conf *visorconfig.V1) {
}
}

// GetAvailPublicVPNServers gets all available public VPN server from service discovery URL
func GetAvailPublicVPNServers(conf *visorconfig.V1) []string {
sdClient := servicedisc.NewClient(log, servicedisc.Config{
Type: servicedisc.ServiceTypeVPN,
PK: conf.PK,
SK: conf.SK,
DiscAddr: conf.Launcher.ServiceDisc,
})
//ctx, _ := context.WithTimeout(context.Background(), 7*time.Second)
vpnServers, err := sdClient.Services(context.Background(), 0)
if err != nil {
log.Error("Error getting public vpn servers: ", err)
return nil
}
serverAddrs := make([]string, len(vpnServers))
for idx, server := range vpnServers {
serverAddrs[idx] = server.Addr.PubKey().String()
}
return serverAddrs
}

func initUninstallBtn() {
if !checkIsPackage() {
mUninstall.Hide()
Expand Down
17 changes: 17 additions & 0 deletions internal/gui/gui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,26 @@ package gui
import (
"testing"

"github.com/skycoin/dmsg/cipher"
"github.com/stretchr/testify/require"

"github.com/skycoin/skywire/pkg/visor/visorconfig"
)

func TestGetAvailPublicVPNServers(t *testing.T) {
pk, sk := cipher.GenerateKeyPair()
common := &visorconfig.Common{
Version: "v1.1.0",
SK: sk,
PK: pk,
}
config := visorconfig.MakeBaseConfig(common)
servers := GetAvailPublicVPNServers(config)
require.NotEqual(t, nil, servers)
require.NotEqual(t, []string{}, servers)
t.Logf("Servers: %v", servers)
}

func TestReadEmbeddedIcon(t *testing.T) {
b, err := ReadSysTrayIcon()
require.NoError(t, err)
Expand Down

0 comments on commit e264ec5

Please sign in to comment.