macOS: Deactivate any active tunnel when app exits

This commit is contained in:
Roopesh Chander 2019-01-23 16:31:26 +05:30
parent 8c64f28742
commit c45f591f8b
2 changed files with 7 additions and 1 deletions

View File

@ -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 {

View File

@ -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