tunsafe-clang15/installer/tunsafe.nsi
Ludvig Strigeus cf92ac7a0c Updates for TunSafe 1.4-rc1
1.Subfolders in the Config/ directory now show up as submenus.
2.Added a way to run TunSafe as a Windows Service.
  Foreground Mode: The service will disconnect when TunSafe closes.
  Background Mode: The service will stay connected in the background.
  No longer required to run the TunSafe client as Admin as long as
  the service is running.
3.New config setting [Interface].ExcludedIPs to configure IPs that
  should not be routed through TunSafe.
4.Can now automatically start TunSafe when Windows starts
5.New UI with tabs and graphs
6.Cache DNS queries to ensure DNS will succeed if connection fails
7.Recreate tray icon when explorer.exe restarts
8.Renamed window title to TunSafe instead of TunSafe VPN Client
9.Main window is now resizable
10.Disallow roaming endpoint when using AllowedIPs=0.0.0.0/0
   Only the original endpoint is added in the routing table so
   this would result in an endless loop of packets.
11.Display approximate Wireguard framing overhead in stats
12.Preparations for protocol handling with multiple threads
13.Delete the routes we made when disconnecting
14.Fix error message about unable to delete a route when connecting
2018-08-12 03:30:06 +02:00

221 lines
6.9 KiB
Plaintext

; ****************************************************************************
; * Copyright (C) 2018 Ludde *
; ****************************************************************************
SetCompressor /SOLID lzma
!addplugindir .
!include "MUI2.nsh"
!include "x64.nsh"
!define MULTIUSER_EXECUTIONLEVEL Admin
!include "MultiUser.nsh"
!include "servicelib.nsh"
!insertmacro GetParameters
!insertmacro GetOptions
!define PRODUCT_NAME "TunSafe"
!define PRODUCT_PUBLISHER "TunSafe"
OutFile "TunSafe-${PRODUCT_VERSION}.exe"
BrandingText " "
ShowInstDetails show
ShowUninstDetails show
Name "${PRODUCT_NAME}"
!define MUI_COMPONENTSPAGE_SMALLDESC
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_ABORTWARNING
!define MUI_ICON "icon.ico"
!define MUI_UNICON "icon.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "tap\install-whirl.bmp"
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
!define MUI_TEXT_LICENSE_TITLE "Welcome to the TunSafe installer"
#!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "LICENSE.TXT"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
#!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
#!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
LangString DESC_SecTAP ${LANG_ENGLISH} "Install the TunSafe client."
LangString DESC_SecTapAdapter ${LANG_ENGLISH} "Download and Install the TunSafe-TAP Virtual Ethernet Adapter (GPL)."
Section "TunSafe Client" SecTunSafe
SetOverwrite on
${If} ${RunningX64}
DetailPrint "Installing 64-bit version of TunSafe."
SetOutPath "$INSTDIR"
File "x64\TunSafe.exe"
${Else}
DetailPrint "Installing 32-bit version of TunSafe."
SetOutPath "$INSTDIR"
File "x86\TunSafe.exe"
${EndIf}
File "License.txt"
File "ChangeLog.txt"
CreateDirectory "$INSTDIR\Config"
SetOutPath "$INSTDIR\Config"
File "TunSafe.conf"
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\TunSafe.lnk" "$INSTDIR\TunSafe.exe" ""
SectionEnd
Section "TunSafe-TAP Ethernet Adapter (GPL)" SecTapAdapter
SetOverwrite on
Delete "$INSTDIR\tunsafe-tap-installer.exe"
NSISdl::download http://tunsafe.com/downloads/TunSafe-TAP-auto.exe "$INSTDIR\TunSafe-TAP Installer.exe"
Pop $R0 ;Get the return value
${Unless} $R0 == "success"
MessageBox MB_ICONEXCLAMATION "An error occurred while downloading the TunSafe-TAP Virtual Ethernet Adapter. The installer will now abort."
SetErrorLevel 1
Quit
${EndUnless}
NSISdl::download http://tunsafe.com/downloads/TunSafe-TAP-auto.exe.sig "$INSTDIR\TunSafe-TAP Installer.exe.sig"
${Unless} $R0 == "success"
Delete "$INSTDIR\TunSafe-TAP Installer.exe.sig"
MessageBox MB_ICONEXCLAMATION "An error occurred while downloading the TunSafe-TAP Virtual Ethernet Adapter. The installer will now abort."
SetErrorLevel 1
Quit
${EndUnless}
SignPlugin::myFunction "$INSTDIR\TunSafe-TAP Installer.exe"
Pop $R1 ;Get the return value
Delete "$INSTDIR\TunSafe-TAP Installer.exe.sig"
${Unless} $R1 = 0
MessageBox MB_ICONEXCLAMATION "The TunSafe-TAP installer that was downloaded is broken (error $R1). The installer will now abort."
SetErrorLevel 1
Quit
${EndUnless}
HideWindow
# Launch TunSafe-TAP installer
ExecWait '"$INSTDIR\TunSafe-TAP Installer.exe" /X /D=$INSTDIR\TAP' $1
ShowWindow $HWNDPARENT ${SW_SHOW}
${Unless} $1 = 0
MessageBox MB_ICONEXCLAMATION "An error occurred while installing the TunSafe-TAP Virtual Ethernet Adapter. The installer will now abort."
SetErrorLevel 1
Quit
${EndUnless}
BringToFront
SectionEnd
Function CloseTunsafe
again:
FindWindow $0 "TunSafe-f19e092db01cbe0fb6aee132f8231e5b71c98f90"
IntCmp $0 0 done
MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "TunSafe is currently started. The installer will close TunSafe and proceed with the installation." IDOK proceed
Quit
proceed:
SendMessage $0 1034 1 0 $1
IntCmp $1 31337 proceed2
MessageBox MB_ICONEXCLAMATION|MB_OKCANCEL "Unable to close TunSafe. Please close it and press OK to continue." IDOK again
Quit
proceed2:
Sleep 500
Goto again
done:
!insertmacro SERVICE stop TunSafeService ""
FunctionEnd
Function .onInit
${GetParameters} $R0
ClearErrors
${IfNot} ${AtLeastWin7}
MessageBox MB_OK "TunSafe requires at least Windows 7"
SetErrorLevel 1
Quit
${EndIf}
Call CloseTunsafe
!insertmacro MULTIUSER_INIT
SetShellVarContext all
${If} $INSTDIR == ""
StrCpy $1 "$PROGRAMFILES\TunSafe"
${If} ${RunningX64}
SetRegView 64
StrCpy $1 "$PROGRAMFILES64\TunSafe"
${EndIf}
ReadRegStr $INSTDIR HKLM "SOFTWARE\${PRODUCT_NAME}" ""
StrCmp $INSTDIR "" 0 +2
StrCpy $INSTDIR $1
${EndIf}
FunctionEnd
Section -post
SetOverwrite on
SetOutPath $INSTDIR
WriteRegStr HKLM SOFTWARE\${PRODUCT_NAME} "" $INSTDIR
; Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"
; Show up in Add/Remove programs
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
WriteRegExpandStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayIcon" "$INSTDIR\TunSafe.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoModify" 1
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "NoRepair" 1
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "HelpLink" "https://tunsafe.com"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" "URLInfoAbout" "https://tunsafe.com"
SectionEnd
Function .onInstSuccess
ExecShell "" "$INSTDIR\TunSafe.exe"
FunctionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecTunSafe} $(DESC_SecTAP)
!insertmacro MUI_DESCRIPTION_TEXT ${SecTapAdapter} $(DESC_SecTapAdapter)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
Function un.onInit
ClearErrors
!insertmacro MULTIUSER_UNINIT
SetShellVarContext all
${If} ${RunningX64}
SetRegView 64
${EndIf}
FunctionEnd
Section "Uninstall"
!insertmacro SERVICE stop "TunSafeService" ""
!insertmacro SERVICE delete "TunSafeService" ""
Delete "$INSTDIR\TunSafe.exe"
Delete "$INSTDIR\License.txt"
Delete "$INSTDIR\ChangeLog.txt"
Delete "$INSTDIR\Config\TunSafe.conf"
Delete "$INSTDIR\Uninstall.exe"
Delete "$INSTDIR\TunSafe-TAP Installer.exe"
RMDir "$INSTDIR"
RMDir "$INSTDIR\Config"
RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
DeleteRegKey HKLM "SOFTWARE\${PRODUCT_NAME}"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
SectionEnd