aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/ui.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-12 00:04:40 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-12 03:07:59 -0600
commit9b7fd388c52d7814953da71cb6af74dd3f3c3922 (patch)
tree9e620accca016b1520f9437ceb6c948ea53f46a1 /ui/ui.go
parenttunneltracker: redo deletion state machine (diff)
downloadwireguard-windows-9b7fd388c52d7814953da71cb6af74dd3f3c3922.tar.xz
wireguard-windows-9b7fd388c52d7814953da71cb6af74dd3f3c3922.zip
tunneltracker: don't track tunnels that haven't been started
Otherwise we get the hasn't-been-started-yet error, and the tracker quits. Meanwhile this is reported back to the ui as an error. While we're at it, don't let multiple trackers be run, in the event that the at-start tracker races with the installation tracker. And, make sure we actually get the deletion notification. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui/ui.go')
-rw-r--r--ui/ui.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/ui/ui.go b/ui/ui.go
index cdfc8472..7bc49489 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -157,7 +157,6 @@ func RunUI() {
return
}
restoreState = false
- runningTunnel = nil
return
}
c, err := conf.FromWgQuick(se.Text(), "test")
@@ -177,7 +176,6 @@ func RunUI() {
return
}
restoreState = false
- runningTunnel = &tunnel
})
quitAction := walk.NewAction()
@@ -209,12 +207,14 @@ func RunUI() {
//TODO: also set tray icon to reflect state
switch state {
case service.TunnelStarting:
+ runningTunnel = tunnel
showRunningView(false)
se.SetEnabled(false)
pb.SetText("Starting...")
pb.SetEnabled(false)
tray.SetToolTip("WireGuard: Activating...")
case service.TunnelStarted:
+ runningTunnel = tunnel
showRunningView(true)
se.SetEnabled(false)
pb.SetText("Stop")
@@ -225,6 +225,7 @@ func RunUI() {
tray.ShowInfo("WireGuard Activated", fmt.Sprintf("The %s tunnel has been activated.", tunnel.Name))
}
case service.TunnelStopping:
+ runningTunnel = tunnel
showRunningView(false)
se.SetEnabled(false)
pb.SetText("Stopping...")
@@ -232,18 +233,15 @@ func RunUI() {
tray.SetToolTip("WireGuard: Deactivating...")
case service.TunnelStopped:
showRunningView(false)
- if runningTunnel != nil {
- runningTunnel.Stop()
- runningTunnel = nil
- }
se.SetEnabled(true)
pb.SetText("Start")
pb.SetEnabled(true)
tray.SetToolTip("WireGuard: Deactivated")
- if showNotifications {
+ if showNotifications && runningTunnel != nil {
//TODO: ShowCustom with right icon
tray.ShowInfo("WireGuard Deactivated", fmt.Sprintf("The %s tunnel has been deactivated.", tunnel.Name))
}
+ runningTunnel = nil
}
mw.SetSuspended(false)
}
@@ -267,8 +265,10 @@ func RunUI() {
if err != nil {
continue
}
- runningTunnel = &tunnel
- setServiceState(&tunnel, state, false)
+ if tunnel.Name == "test" && state != service.TunnelStopped {
+ runningTunnel = &tunnel
+ setServiceState(&tunnel, state, false)
+ }
}
}()