Reassign tunnelProvider if it changes from outside the app

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-12-22 06:56:12 +01:00
parent 0bec5b04b0
commit 49bf55021f
1 changed files with 4 additions and 2 deletions

View File

@ -281,7 +281,9 @@ class TunnelsManager {
guard let self = self,
let session = statusChangeNotification.object as? NETunnelProviderSession,
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)'")
@ -364,7 +366,7 @@ class TunnelContainer: NSObject {
var activationAttemptId: String?
var activationTimer: Timer?
fileprivate let tunnelProvider: NETunnelProviderManager
fileprivate var tunnelProvider: NETunnelProviderManager
private var lastTunnelConnectionStatus: NEVPNStatus?
var tunnelConfiguration: TunnelConfiguration? {