UI: Consider on-demand to be enabled iff the tunnel provider is enabled
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
ca70fe9ddc
commit
cfd1b16801
|
@ -344,7 +344,8 @@ class TunnelsManager {
|
||||||
|
|
||||||
func setOnDemandEnabled(_ isOnDemandEnabled: Bool, on tunnel: TunnelContainer, completionHandler: @escaping (TunnelsManagerError?) -> Void) {
|
func setOnDemandEnabled(_ isOnDemandEnabled: Bool, on tunnel: TunnelContainer, completionHandler: @escaping (TunnelsManagerError?) -> Void) {
|
||||||
let tunnelProviderManager = tunnel.tunnelProvider
|
let tunnelProviderManager = tunnel.tunnelProvider
|
||||||
guard tunnelProviderManager.isOnDemandEnabled != isOnDemandEnabled else {
|
let isCurrentlyEnabled = (tunnelProviderManager.isOnDemandEnabled && tunnelProviderManager.isEnabled)
|
||||||
|
guard isCurrentlyEnabled != isOnDemandEnabled else {
|
||||||
completionHandler(nil)
|
completionHandler(nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -571,7 +572,7 @@ class TunnelContainer: NSObject {
|
||||||
|
|
||||||
fileprivate var tunnelProvider: NETunnelProviderManager {
|
fileprivate var tunnelProvider: NETunnelProviderManager {
|
||||||
didSet {
|
didSet {
|
||||||
isActivateOnDemandEnabled = tunnelProvider.isOnDemandEnabled
|
isActivateOnDemandEnabled = tunnelProvider.isOnDemandEnabled && tunnelProvider.isEnabled
|
||||||
hasOnDemandRules = !(tunnelProvider.onDemandRules ?? []).isEmpty
|
hasOnDemandRules = !(tunnelProvider.onDemandRules ?? []).isEmpty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -594,7 +595,7 @@ class TunnelContainer: NSObject {
|
||||||
name = tunnel.localizedDescription ?? "Unnamed"
|
name = tunnel.localizedDescription ?? "Unnamed"
|
||||||
let status = TunnelStatus(from: tunnel.connection.status)
|
let status = TunnelStatus(from: tunnel.connection.status)
|
||||||
self.status = status
|
self.status = status
|
||||||
isActivateOnDemandEnabled = tunnel.isOnDemandEnabled
|
isActivateOnDemandEnabled = tunnel.isOnDemandEnabled && tunnel.isEnabled
|
||||||
hasOnDemandRules = !(tunnel.onDemandRules ?? []).isEmpty
|
hasOnDemandRules = !(tunnel.onDemandRules ?? []).isEmpty
|
||||||
tunnelProvider = tunnel
|
tunnelProvider = tunnel
|
||||||
super.init()
|
super.init()
|
||||||
|
|
Loading…
Reference in New Issue