Skip to content

Commit

Permalink
Merge pull request #1081 from mrpalide/feature/add-wintun-to-windows-…
Browse files Browse the repository at this point in the history
…installer

Add wintun.dll
  • Loading branch information
jdknives authored Feb 7, 2022
2 parents 1dfb04c + 6f8f862 commit bf4f0aa
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 30 deletions.
5 changes: 0 additions & 5 deletions cmd/skywire-cli/commands/config/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ var genConfigCmd = &cobra.Command{
}
}

// Check os to set bin_path address
if selectedOS == "windows" {
conf.Launcher.BinPath = "C:\\Program Files\\Skywire"
}

// Read in old config (if any) and obtain old hypervisors.
if replaceHypervisors {
if oldConf, ok := readOldConfig(mLog, output, true); ok {
Expand Down
40 changes: 19 additions & 21 deletions internal/gui/gui.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package gui

import (
"context"
"embed"
"fmt"
"io"
Expand All @@ -20,7 +19,6 @@ 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 @@ -193,25 +191,25 @@ 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 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() {
Expand Down
19 changes: 19 additions & 0 deletions pkg/visor/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package visor
import (
"context"
"encoding/hex"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -316,6 +317,10 @@ func (v *Visor) StartApp(appName string) error {
if err != nil {
return err
}

if v.GetVPNClientAddress() == "" {
return errors.New("VPN server pub key is missing")
}
}

return v.appL.StartApp(appName, nil, envs)
Expand Down Expand Up @@ -807,3 +812,17 @@ func (v *Visor) GetPersistentTransports() ([]transport.PersistentTransports, err
func (v *Visor) SetPublicAutoconnect(pAc bool) error {
return v.conf.UpdatePublicAutoconnect(pAc)
}

// GetVPNClientAddress get PK address of server set on vpn-client
func (v *Visor) GetVPNClientAddress() string {
for _, v := range v.conf.Launcher.Apps {
if v.Name == skyenv.VPNClientName {
for index := range v.Args {
if v.Args[index] == "-srv" {
return v.Args[index+1]
}
}
}
}
return ""
}
6 changes: 6 additions & 0 deletions scripts/win_installer/script.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
echo "Building Systray Windows Binaries..."
if (Test-Path ".\skywire.msi") { Remove-Item ".\skywire.msi" -Recurse -Force}
if (Test-Path ".\wintun.zip") { Remove-Item ".\wintun.zip" -Recurse -Force}
make build-systray-windows > $null
echo "Build Complete!"
echo "Setting go-msi configuration..."
Expand All @@ -12,6 +13,11 @@ mv ..\..\apps\vpn-client .\build\amd64\apps\vpn-client.exe
rm ..\..\setup-node.exe
rm -r -fo ..\..\apps
cp skywire.bat .\build\amd64\skywire.bat
curl "https://www.wintun.net/builds/wintun-0.14.1.zip" -o wintun.zip
tar -xf wintun.zip
cp .\wintun\bin\amd64\wintun.dll .\build\amd64\wintun.dll
rm -r -fo wintun
rm wintun.zip
echo "Configuration complete!"
echo "Building msi..."
go-msi make --msi skywire.msi --version 0.5.1 --arch amd64
Expand Down
11 changes: 8 additions & 3 deletions scripts/win_installer/skywire.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
@Echo Off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit
cd /d "%~dp0"
if not exist "apps\" (
mkdir apps
move vpn-client.exe apps
if exist vpn-client.exe (
if not exist "apps\" (
mkdir apps
)
move /Y vpn-client.exe apps
)
if exist "wintun.dll" (
move /Y wintun.dll "C:\Windows\System32"
)
if not exist "%HOMEPATH%\skywire-config.json" (
skywire-cli config gen -biro "%HOMEPATH%\skywire-config.json" --os windows --disable-apps skychat,skysocks,skysocks-client,vpn-server
Expand Down
3 changes: 2 additions & 1 deletion scripts/win_installer/wix.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build/amd64/skywire-visor.exe",
"build/amd64/apps/vpn-client.exe",
"build/amd64/skywire.bat",
"ico.ico"
"ico.ico",
"build/amd64/wintun.dll"
]
},
"env": {
Expand Down

0 comments on commit bf4f0aa

Please sign in to comment.