Tunnels manager: Keep track of NETunnelProviderManager's isOnDemandEnabled property
Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
parent
abb0312d38
commit
923d039a78
|
@ -226,10 +226,10 @@ class TunnelsListTableViewController: UIViewController {
|
||||||
|
|
||||||
func refreshTunnelConnectionStatuses() {
|
func refreshTunnelConnectionStatuses() {
|
||||||
if let tunnelsManager = tunnelsManager {
|
if let tunnelsManager = tunnelsManager {
|
||||||
tunnelsManager.refreshConnectionStatuses()
|
tunnelsManager.refreshStatuses()
|
||||||
} else {
|
} else {
|
||||||
onTunnelsManagerReady = { tunnelsManager in
|
onTunnelsManagerReady = { tunnelsManager in
|
||||||
tunnelsManager.refreshConnectionStatuses()
|
tunnelsManager.refreshStatuses()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,8 @@ class TunnelsManager {
|
||||||
tunnel.beginRestart()
|
tunnel.beginRestart()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tunnel.isActivateOnDemandEnabled = tunnelProviderManager.isOnDemandEnabled
|
||||||
|
|
||||||
completionHandler(nil)
|
completionHandler(nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,9 +217,9 @@ class TunnelsManager {
|
||||||
tunnel.startDeactivation()
|
tunnel.startDeactivation()
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshConnectionStatuses() {
|
func refreshStatuses() {
|
||||||
for t in tunnels {
|
for t in tunnels {
|
||||||
t.refreshConnectionStatus()
|
t.refreshStatus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,6 +227,7 @@ class TunnelsManager {
|
||||||
class TunnelContainer: NSObject {
|
class TunnelContainer: NSObject {
|
||||||
@objc dynamic var name: String
|
@objc dynamic var name: String
|
||||||
@objc dynamic var status: TunnelStatus
|
@objc dynamic var status: TunnelStatus
|
||||||
|
@objc dynamic var isActivateOnDemandEnabled: Bool
|
||||||
|
|
||||||
var onDeactivationComplete: (() -> Void)?
|
var onDeactivationComplete: (() -> Void)?
|
||||||
|
|
||||||
|
@ -235,6 +238,7 @@ class TunnelContainer: NSObject {
|
||||||
self.name = tunnel.localizedDescription ?? "Unnamed"
|
self.name = tunnel.localizedDescription ?? "Unnamed"
|
||||||
let status = TunnelStatus(from: tunnel.connection.status)
|
let status = TunnelStatus(from: tunnel.connection.status)
|
||||||
self.status = status
|
self.status = status
|
||||||
|
self.isActivateOnDemandEnabled = tunnel.isOnDemandEnabled
|
||||||
self.tunnelProvider = tunnel
|
self.tunnelProvider = tunnel
|
||||||
super.init()
|
super.init()
|
||||||
if (status != .inactive) {
|
if (status != .inactive) {
|
||||||
|
@ -250,9 +254,10 @@ class TunnelContainer: NSObject {
|
||||||
return ActivateOnDemandSetting(from: tunnelProvider)
|
return ActivateOnDemandSetting(from: tunnelProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshConnectionStatus() {
|
func refreshStatus() {
|
||||||
let status = TunnelStatus(from: self.tunnelProvider.connection.status)
|
let status = TunnelStatus(from: self.tunnelProvider.connection.status)
|
||||||
self.status = status
|
self.status = status
|
||||||
|
self.isActivateOnDemandEnabled = self.tunnelProvider.isOnDemandEnabled
|
||||||
if (status != .inactive) {
|
if (status != .inactive) {
|
||||||
startObservingTunnelStatus()
|
startObservingTunnelStatus()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue