aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-01-23 16:31:26 +0530
committerRoopesh Chander <roop@roopc.net>2019-01-23 16:31:30 +0530
commite5a76be6fdf0d1365d6cb8d3f3df517d615d4b3a (patch)
tree5609d6b10c46b3cac1e309d868d8648980fd0d82
parentmacOS: Adapt to TunnelsManagerListDelegate changes (diff)
downloadwireguard-apple-e5a76be6fdf0d1365d6cb8d3f3df517d615d4b3a.tar.xz
wireguard-apple-e5a76be6fdf0d1365d6cb8d3f3df517d615d4b3a.zip
macOS: Deactivate any active tunnel when app exits
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/UI/macOS/AppDelegate.swift6
-rw-r--r--WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift2
2 files changed, 7 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift
index 76ac0008..5546eef1 100644
--- a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift
+++ b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift
@@ -40,6 +40,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
self.statusItemController = statusItemController
}
}
+
+ func applicationWillTerminate(_ notification: Notification) {
+ if let currentTunnel = tunnelsTracker?.currentTunnel {
+ tunnelsManager?.startDeactivation(of: currentTunnel)
+ }
+ }
}
extension AppDelegate: StatusMenuWindowDelegate {
diff --git a/WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift b/WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift
index 3d29b02d..9c931869 100644
--- a/WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift
+++ b/WireGuard/WireGuard/UI/macOS/TunnelsTracker.swift
@@ -16,7 +16,7 @@ class TunnelsTracker {
private var tunnelsManager: TunnelsManager
private var tunnelStatusObservers = [AnyObject]()
- private var currentTunnel: TunnelContainer? {
+ private(set) var currentTunnel: TunnelContainer? {
didSet {
statusMenu?.currentTunnel = currentTunnel
statusItemController?.currentTunnel = currentTunnel