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