From a3b262552ec69454121db5d328d68a5b93ab956c Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Fri, 6 May 2022 05:35:26 +0430 Subject: [PATCH 01/10] add checking for update to regenrate config file --- scripts/win_installer/script.ps1 | 2 ++ scripts/win_installer/skywire.bat | 6 +++++- scripts/win_installer/wix.json | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/win_installer/script.ps1 b/scripts/win_installer/script.ps1 index f9838bfd20..58a19f4195 100644 --- a/scripts/win_installer/script.ps1 +++ b/scripts/win_installer/script.ps1 @@ -14,6 +14,8 @@ cp ..\..\dmsghttp-config.json .\build\amd64\dmsghttp-config.json rm ..\..\setup-node.exe rm -r -fo ..\..\apps cp skywire.bat .\build\amd64\skywire.bat +ni new.update +mv new.update .\build\amd64\new.update 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 diff --git a/scripts/win_installer/skywire.bat b/scripts/win_installer/skywire.bat index a557d9fb39..a8d25932b7 100644 --- a/scripts/win_installer/skywire.bat +++ b/scripts/win_installer/skywire.bat @@ -14,7 +14,11 @@ if exist "%HOMEPATH%\skywire-config.json" ( move /Y "%HOMEPATH%\skywire-config.json" . ) if not exist "skywire-config.json" ( -skywire-cli config gen -birp --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server + skywire-cli config gen -birp --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server +) +if exist "new.update" ( + skywire-cli config gen -birpx --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server + del new.update ) start "" http://127.0.0.1:8000 skywire-visor.exe -c "skywire-config.json" diff --git a/scripts/win_installer/wix.json b/scripts/win_installer/wix.json index 9a73d69b87..c29c54583b 100644 --- a/scripts/win_installer/wix.json +++ b/scripts/win_installer/wix.json @@ -11,7 +11,8 @@ "build/amd64/skywire.bat", "ico.ico", "build/amd64/wintun.dll", - "build/amd64/dmsghttp-config.json" + "build/amd64/dmsghttp-config.json", + "build/amd64/new.update" ] }, "env": { From bc8f6368947e0c104738a66b39cc5e54ef53c0c3 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Fri, 6 May 2022 07:13:35 +0430 Subject: [PATCH 02/10] make more efficient skywrie.bat file --- scripts/win_installer/skywire.bat | 40 ++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/scripts/win_installer/skywire.bat b/scripts/win_installer/skywire.bat index a8d25932b7..b5fd7e019d 100644 --- a/scripts/win_installer/skywire.bat +++ b/scripts/win_installer/skywire.bat @@ -1,24 +1,62 @@ @Echo Off +:: Open Powershell with Administrator privilege %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("powershell.exe","/c %~s0 ::","","runas",1)(window.close)&&exit cd /d "%~dp0" + +:: Set start time +for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" +set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" & set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" +set "start_time=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%" + +:: Print screen message to users +echo: +echo ####################################################################### +echo # # +echo # Welcome to Skywire [Windows] # +echo # # +echo # - You have access to Hyperviro UI by http://127.0.0.1:8000 # +echo # - All logs available in C:\Program Files\Skywire\local\logs # +echo # - You can terminate skywire by Ctrl+C command # +echo # # +echo ####################################################################### +echo: + +:: Create logs folder if not exist. Run just in first time after install +if not exist "local\logs\" ( + mkdir "local\logs" +) + +:: Move vpn-client.exe to its path if exist vpn-client.exe ( if not exist "apps\" ( mkdir apps ) move /Y vpn-client.exe apps ) + +:: Move wintun.dll to system32 path if exist "wintun.dll" ( move /Y wintun.dll "C:\Windows\System32" ) + +:: Move existed config file in user home to here if exist "%HOMEPATH%\skywire-config.json" ( move /Y "%HOMEPATH%\skywire-config.json" . ) + +:: Genereate new config file if not exist if not exist "skywire-config.json" ( skywire-cli config gen -birp --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server ) + +:: After update and install new version of skywire, regenerate config file for update values and version if exist "new.update" ( skywire-cli config gen -birpx --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server del new.update ) + +:: Open UI start "" http://127.0.0.1:8000 -skywire-visor.exe -c "skywire-config.json" + +:: Run skywire +skywire-visor.exe -c "skywire-config.json" >> local\logs\skywire_%start_time%.log From 840a54cfa096e2098c121090c599884790aa8faa Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Fri, 6 May 2022 07:24:48 +0430 Subject: [PATCH 03/10] clean skywire.bat | fix typo --- scripts/win_installer/skywire.bat | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/win_installer/skywire.bat b/scripts/win_installer/skywire.bat index b5fd7e019d..b1bdda32eb 100644 --- a/scripts/win_installer/skywire.bat +++ b/scripts/win_installer/skywire.bat @@ -1,32 +1,32 @@ @Echo Off -:: Open Powershell with Administrator privilege +:: Opening Powershell with Administrator privilege %1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("powershell.exe","/c %~s0 ::","","runas",1)(window.close)&&exit cd /d "%~dp0" -:: Set start time +:: Setting start time for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" & set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" set "start_time=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%" -:: Print screen message to users +:: Printing screen message to users echo: -echo ####################################################################### -echo # # -echo # Welcome to Skywire [Windows] # -echo # # -echo # - You have access to Hyperviro UI by http://127.0.0.1:8000 # -echo # - All logs available in C:\Program Files\Skywire\local\logs # -echo # - You can terminate skywire by Ctrl+C command # -echo # # -echo ####################################################################### +echo ######################################################################## +echo # # +echo # Welcome to Skywire [Windows] # +echo # # +echo # - You have access to Hypervisor UI by http://127.0.0.1:8000 # +echo # - All logs be available in C:\Program Files\Skywire\local\logs # +echo # - You can terminate Skywire by Ctrl+C command. # +echo # # +echo ######################################################################## echo: -:: Create logs folder if not exist. Run just in first time after install +:: Creating logs folder if not exist [Run just in first time after installing] if not exist "local\logs\" ( mkdir "local\logs" ) -:: Move vpn-client.exe to its path +:: Moving vpn-client.exe to its path if exist vpn-client.exe ( if not exist "apps\" ( mkdir apps @@ -34,29 +34,29 @@ if exist vpn-client.exe ( move /Y vpn-client.exe apps ) -:: Move wintun.dll to system32 path +:: Moving wintun.dll to system32 path if exist "wintun.dll" ( move /Y wintun.dll "C:\Windows\System32" ) -:: Move existed config file in user home to here +:: Moving existed config file in user home to installation path if exist "%HOMEPATH%\skywire-config.json" ( move /Y "%HOMEPATH%\skywire-config.json" . ) -:: Genereate new config file if not exist +:: Generating new config file if not exist if not exist "skywire-config.json" ( skywire-cli config gen -birp --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server ) -:: After update and install new version of skywire, regenerate config file for update values and version +:: Regenerating config file after update and install new version of Skywire if exist "new.update" ( skywire-cli config gen -birpx --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server del new.update ) -:: Open UI +:: Opening UI start "" http://127.0.0.1:8000 -:: Run skywire +:: Running Skywire skywire-visor.exe -c "skywire-config.json" >> local\logs\skywire_%start_time%.log From b0528908d8f9adf7678200e0baa4c09efd1fcbd7 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Fri, 6 May 2022 07:49:49 +0430 Subject: [PATCH 04/10] do not showing useless output in powershell screen --- scripts/win_installer/skywire.bat | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/win_installer/skywire.bat b/scripts/win_installer/skywire.bat index b1bdda32eb..e765d1f8e0 100644 --- a/scripts/win_installer/skywire.bat +++ b/scripts/win_installer/skywire.bat @@ -23,36 +23,36 @@ echo: :: Creating logs folder if not exist [Run just in first time after installing] if not exist "local\logs\" ( - mkdir "local\logs" + mkdir "local\logs" >nul 2>&1 ) :: Moving vpn-client.exe to its path if exist vpn-client.exe ( if not exist "apps\" ( - mkdir apps + mkdir apps >nul 2>&1 ) - move /Y vpn-client.exe apps + move /Y vpn-client.exe apps >nul 2>&1 ) :: Moving wintun.dll to system32 path if exist "wintun.dll" ( - move /Y wintun.dll "C:\Windows\System32" + move /Y wintun.dll "C:\Windows\System32" >nul 2>&1 ) :: Moving existed config file in user home to installation path if exist "%HOMEPATH%\skywire-config.json" ( - move /Y "%HOMEPATH%\skywire-config.json" . + move /Y "%HOMEPATH%\skywire-config.json" . >nul 2>&1 ) :: Generating new config file if not exist if not exist "skywire-config.json" ( - skywire-cli config gen -birp --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server + skywire-cli config gen -birpw --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server >nul 2>&1 ) :: Regenerating config file after update and install new version of Skywire if exist "new.update" ( - skywire-cli config gen -birpx --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server - del new.update + skywire-cli config gen -birpwx --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server >nul 2>&1 + del new.update >nul 2>&1 ) :: Opening UI From 14d6c1525cfe198b932a9bd448620b382f61d04e Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Fri, 6 May 2022 07:52:26 +0430 Subject: [PATCH 05/10] do not showing useless output in powershell screen | cleaning --- scripts/win_installer/skywire.bat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/win_installer/skywire.bat b/scripts/win_installer/skywire.bat index e765d1f8e0..a2eade3723 100644 --- a/scripts/win_installer/skywire.bat +++ b/scripts/win_installer/skywire.bat @@ -23,30 +23,30 @@ echo: :: Creating logs folder if not exist [Run just in first time after installing] if not exist "local\logs\" ( - mkdir "local\logs" >nul 2>&1 + mkdir "local\logs" >nul 2>&1 ) :: Moving vpn-client.exe to its path if exist vpn-client.exe ( if not exist "apps\" ( - mkdir apps >nul 2>&1 + mkdir apps >nul 2>&1 ) move /Y vpn-client.exe apps >nul 2>&1 ) :: Moving wintun.dll to system32 path if exist "wintun.dll" ( - move /Y wintun.dll "C:\Windows\System32" >nul 2>&1 + move /Y wintun.dll "C:\Windows\System32" >nul 2>&1 ) :: Moving existed config file in user home to installation path if exist "%HOMEPATH%\skywire-config.json" ( - move /Y "%HOMEPATH%\skywire-config.json" . >nul 2>&1 + move /Y "%HOMEPATH%\skywire-config.json" . >nul 2>&1 ) :: Generating new config file if not exist if not exist "skywire-config.json" ( - skywire-cli config gen -birpw --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server >nul 2>&1 + skywire-cli config gen -birpw --os windows --disableapps skychat,skysocks,skysocks-client,vpn-server >nul 2>&1 ) :: Regenerating config file after update and install new version of Skywire From 3f9ee66be1f13e5b8b258aae5de7e735c68490a3 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Fri, 6 May 2022 07:53:47 +0430 Subject: [PATCH 06/10] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 81e7d37179..e7982deb2b 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,4 @@ Char /scripts/mac_installer/icon.iconset/ releaseChangelog.md skywire.msi +/scripts/win_installer/build/ From 8f82c8892987f633413809aabf31313fbfd7aa19 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Fri, 6 May 2022 13:11:12 +0430 Subject: [PATCH 07/10] fix server click on server list issue --- internal/gui/gui.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/gui/gui.go b/internal/gui/gui.go index 9187304973..019e13bb5f 100644 --- a/internal/gui/gui.go +++ b/internal/gui/gui.go @@ -274,7 +274,7 @@ func serversBtn(conf *visorconfig.V1, servers []*systray.MenuItem, rpcClient vis for { selectedServer := servers[<-btnChannel] serverTempValue := strings.Split(selectedServer.String(), ",")[2] - serverPK := serverTempValue[2 : len(serverTempValue)-5] + serverPK := serverTempValue[2 : len(serverTempValue)-7] for _, server := range servers { server.Uncheck() server.Enable() @@ -351,7 +351,7 @@ func getAvailPublicVPNServers(conf *visorconfig.V1, httpC *http.Client, logger * if server.Geo != nil { serverAddrs[idx] = server.Addr.PubKey().String() + " | " + server.Geo.Country } else { - serverAddrs[idx] = server.Addr.PubKey().String() + " | N/A" + serverAddrs[idx] = server.Addr.PubKey().String() + " | NA" } } return serverAddrs From 6fec6f840d8032c9781f94430d677da1920f3da5 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Tue, 10 May 2022 11:19:28 +0430 Subject: [PATCH 08/10] check nil procM before calling GetAppConnectionsSummary --- pkg/visor/api.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/visor/api.go b/pkg/visor/api.go index 05a6991675..c682362cb2 100644 --- a/pkg/visor/api.go +++ b/pkg/visor/api.go @@ -540,12 +540,15 @@ func (v *Visor) GetAppError(appName string) (string, error) { // GetAppConnectionsSummary implements API. func (v *Visor) GetAppConnectionsSummary(appName string) ([]appserver.ConnectionSummary, error) { - cSummary, err := v.procM.ConnectionsSummary(appName) - if err != nil { - return nil, err - } + if v.procM != nil { + cSummary, err := v.procM.ConnectionsSummary(appName) + if err != nil { + return nil, err + } - return cSummary, nil + return cSummary, nil + } + return nil, nil } // TransportTypes implements API. From 9fac96ce8891580425aa87cbcb3b96a0de49a930 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Wed, 11 May 2022 09:31:36 +0430 Subject: [PATCH 09/10] clean code --- internal/gui/gui.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/gui/gui.go b/internal/gui/gui.go index b2c67213a1..31d8333c8c 100644 --- a/internal/gui/gui.go +++ b/internal/gui/gui.go @@ -69,11 +69,8 @@ func GetOnGUIReady(icon []byte, conf *visorconfig.V1) func() { logger := logging.NewMasterLogger() logger.SetLevel(logrus.InfoLevel) - go func() { - - }() - httpC := getHTTPClient(conf, context.Background(), logger) + if isRoot() { return func() { systray.SetTemplateIcon(icon, icon) From bc156b685fdf318398532e7f632b036e62ee5b57 Mon Sep 17 00:00:00 2001 From: MohammadReza Palide Date: Wed, 11 May 2022 10:33:39 +0430 Subject: [PATCH 10/10] fix systray error on windows --- internal/gui/gui.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/gui/gui.go b/internal/gui/gui.go index b2c67213a1..8b04dd6dd0 100644 --- a/internal/gui/gui.go +++ b/internal/gui/gui.go @@ -136,7 +136,6 @@ func initAdvancedButton(conf *visorconfig.V1) { // if it's not installed via package, hide the uninstall button if !checkIsPackage() { mAdvancedButton.Hide() - mUninstall.Hide() } }