Reassign tunnelProvider if it changes from outside the app

This commit is contained in:
Jason A. Donenfeld 2018-12-22 06:56:12 +01:00
parent 8fb8d9a9d2
commit 470da3ffcc
1 changed files with 4 additions and 2 deletions

View File

@ -281,7 +281,9 @@ class TunnelsManager {
guard let self = self, guard let self = self,
let session = statusChangeNotification.object as? NETunnelProviderSession, let session = statusChangeNotification.object as? NETunnelProviderSession,
let tunnelProvider = session.manager as? NETunnelProviderManager, let tunnelProvider = session.manager as? NETunnelProviderManager,
let tunnel = self.tunnels.first(where: { $0.tunnelProvider == tunnelProvider }) else { return } let tunnelConfiguration = TunnelContainer(tunnel: tunnelProvider).tunnelConfiguration,
let tunnel = self.tunnels.first(where: { $0.tunnelConfiguration == tunnelConfiguration }) else { return }
tunnel.tunnelProvider = tunnelProvider
wg_log(.debug, message: "Tunnel '\(tunnel.name)' connection status changed to '\(tunnel.tunnelProvider.connection.status)'") wg_log(.debug, message: "Tunnel '\(tunnel.name)' connection status changed to '\(tunnel.tunnelProvider.connection.status)'")
@ -364,7 +366,7 @@ class TunnelContainer: NSObject {
var activationAttemptId: String? var activationAttemptId: String?
var activationTimer: Timer? var activationTimer: Timer?
fileprivate let tunnelProvider: NETunnelProviderManager fileprivate var tunnelProvider: NETunnelProviderManager
private var lastTunnelConnectionStatus: NEVPNStatus? private var lastTunnelConnectionStatus: NEVPNStatus?
var tunnelConfiguration: TunnelConfiguration? { var tunnelConfiguration: TunnelConfiguration? {