Skip to content

Commit

Permalink
Merge pull request #1 from mattock/respawn
Browse files Browse the repository at this point in the history
Make openvpnserv2's openvpn respawn tests optional
  • Loading branch information
mattock authored Dec 19, 2016
2 parents dbf74cc + 277bf81 commit 45393a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@ Usage

The main script tests only one VPN connection:
::
Usage: Test-Openvpn.ps1 -Config <openvpn-config-file> -Ping <hosts> [-Openvpn <openvpn-exe>] [-Gui <openvpn-gui-exe>] [-TestCmdexe] [-TestService] [-TestGui] [-Help]
Usage: Test-Openvpn.ps1 -Config <openvpn-config-file> -Ping <hosts> [-Openvpn <openvpn-exe>] [-Gui <openvpn-gui-exe>] [-TestCmdexe] [-TestService] [-TestRespawn] [-TestGui] [-Help]
Parameters:
-Openvpn Path to openvpn.exe (defaults to C:\Program Files\OpenVPN\bin\openvpn.exe)
-Gui Path to openvpn-gui.exe (defaults to C:\Program Files\OpenVPN\bin\openvpn-gui.exe)
-Config Path to the OpenVPN configuration file
-Ping Target host(s) inside VPN to ping (should succeed). Separate multiple entries
with commas.
-Suspend Test suspend and resume [UNIMPLEMENTED]
-TestCmdexe Test connection from the command-line
-TestGui Test OpenVPN-GUI
-TestService Test openvpnserv2.exe
-TestRespawn Test if openvpnserv2 is able to respawn a dead connection properly
-Help Display this help
Example: .\Test-Openvpn -Config "C:\Program Files\OpenVPN\config\company.ovpn" -Ping 192.168.40.7 -TestCmdexe -TestService -TestGui
Example: .\Test-Openvpn.ps1 -Config "C:\Program Files\OpenVPN\config\company.ovpn" -Ping 192.168.40.7 -TestCmdexe -TestService -TestGui

To verify that the connections do not succeed because of a bug or by accident,
-Ping a fake IP that can only fail.
Expand Down
12 changes: 8 additions & 4 deletions test-openvpn.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
[array]$Ping,
[switch]$TestCmdexe,
[switch]$TestService,
[switch]$TestRespawn,
[switch]$TestGui,
[switch]$Help
)

Function Show-Usage {
Write-Host "Usage: Test-Openvpn.ps1 -Config <openvpn-config-file> -Ping <host> [-Openvpn <openvpn-exe>] [-Gui <openvpn-gui-exe>] [-TestCmdexe] [-TestService] [-TestGui] [-Help]"
Write-Host "Usage: Test-Openvpn.ps1 -Config <openvpn-config-file> -Ping <hosts> [-Openvpn <openvpn-exe>] [-Gui <openvpn-gui-exe>] [-TestCmdexe] [-TestService] [-TestRespawn] [-TestGui] [-Help]"
Write-Host
Write-Host "Parameters:"
Write-Host " -Openvpn Path to openvpn.exe (defaults to C:\Program Files\OpenVPN\bin\openvpn.exe)"
Expand All @@ -21,6 +22,7 @@ Function Show-Usage {
Write-Host " -TestCmdexe Test connection from the command-line"
Write-Host " -TestGui Test OpenVPN-GUI"
Write-Host " -TestService Test openvpnserv2.exe"
Write-Host " -TestRespawn Test if openvpnserv2 is able to respawn a dead connection properly"
Write-Host " -Help Display this help"
Write-Host
Write-Host "Example: .\Test-Openvpn.ps1 -Config ""C:\Program Files\OpenVPN\config\company.ovpn"" -Ping 192.168.40.7 -TestCmdexe -TestService -TestGui"
Expand Down Expand Up @@ -169,9 +171,11 @@ Function Test-Service {

Start-Service OpenVPNService
Check-Connectivity "openvpnserv2" $ping
# Test if openvpn.exe is respawned correctly on forced kill
Stop-Openvpn
Check-connectivity "openvpnserv2-respawn" $ping

if ($TestRespawn) {
Stop-Openvpn
Check-connectivity "openvpnserv2-respawn" $ping
}
Stop-Service OpenVPNService

foreach ($move in $moved) {
Expand Down

0 comments on commit 45393a6

Please sign in to comment.