aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/service/tunneltracker.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-10 02:37:34 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-10 03:37:23 +0100
commitda563a6ec66113fee96dad3ebf440607320637c6 (patch)
treeac98e26149c9829900e84977569452a2a9274a56 /service/tunneltracker.go
parentinstaller: bring to foreground using shellexec process (diff)
downloadwireguard-windows-da563a6ec66113fee96dad3ebf440607320637c6.tar.xz
wireguard-windows-da563a6ec66113fee96dad3ebf440607320637c6.zip
service: keep track of proper errors
Diffstat (limited to '')
-rw-r--r--service/tunneltracker.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/service/tunneltracker.go b/service/tunneltracker.go
index 89de0c38..ca2b6a45 100644
--- a/service/tunneltracker.go
+++ b/service/tunneltracker.go
@@ -10,6 +10,7 @@ import (
"golang.org/x/sys/windows/svc/mgr"
"golang.zx2c4.com/wireguard/windows/conf"
"runtime"
+ "syscall"
"unsafe"
)
@@ -104,12 +105,21 @@ func trackTunnelService(tunnelName string, svc *mgr.Service) {
if notifier.notificationStatus != 0 {
return
}
+ var tunnelError error
state := TunnelUnknown
if notifier.notificationTriggered&serviceNotify_DELETE_PENDING != 0 {
state = TunnelDeleting
} else if notifier.notificationTriggered&serviceNotify_STOPPED != 0 {
state = TunnelStopped
hasStopped = true
+ if notifier.win32ExitCode == uint32(windows.ERROR_SERVICE_SPECIFIC_ERROR) {
+ maybeErr := Error(notifier.serviceSpecificExitCode)
+ if maybeErr != ErrorSuccess {
+ tunnelError = maybeErr
+ }
+ } else if notifier.win32ExitCode != uint32(windows.NO_ERROR) {
+ tunnelError = syscall.Errno(notifier.win32ExitCode)
+ }
} else if notifier.notificationTriggered&serviceNotify_STOP_PENDING != 0 && hasStopped {
state = TunnelStopping
} else if notifier.notificationTriggered&serviceNotify_RUNNING != 0 {
@@ -119,7 +129,7 @@ func trackTunnelService(tunnelName string, svc *mgr.Service) {
state = TunnelStarting
hasStopped = false
}
- IPCServerNotifyTunnelChange(tunnelName, state)
+ IPCServerNotifyTunnelChange(tunnelName, state, tunnelError)
if state == TunnelDeleting {
return
}