Skip notifications without a bundle identifier
Would raise fatalError in notification getter.
This commit is contained in:
parent
6101e92c3b
commit
92bc00e1fd
|
@ -228,8 +228,10 @@ public class NetworkExtensionVPN: VPN {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func notifyReinstall(_ manager: NETunnelProviderManager) {
|
private func notifyReinstall(_ manager: NETunnelProviderManager) {
|
||||||
let bundleId = manager.tunnelBundleIdentifier
|
guard let bundleId = manager.tunnelBundleIdentifier else {
|
||||||
log.debug("VPN did reinstall (\(bundleId ?? "?")): isEnabled=\(manager.isEnabled)")
|
return
|
||||||
|
}
|
||||||
|
log.debug("VPN did reinstall (\(bundleId)): isEnabled=\(manager.isEnabled)")
|
||||||
|
|
||||||
var notification = Notification(name: VPNNotification.didReinstall)
|
var notification = Notification(name: VPNNotification.didReinstall)
|
||||||
notification.vpnBundleIdentifier = bundleId
|
notification.vpnBundleIdentifier = bundleId
|
||||||
|
@ -242,8 +244,10 @@ public class NetworkExtensionVPN: VPN {
|
||||||
log.verbose("Ignoring VPN notification from bogus manager")
|
log.verbose("Ignoring VPN notification from bogus manager")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let bundleId = connection.manager.tunnelBundleIdentifier
|
guard let bundleId = connection.manager.tunnelBundleIdentifier else {
|
||||||
log.debug("VPN status did change (\(bundleId ?? "?")): isEnabled=\(connection.manager.isEnabled), status=\(connection.status.rawValue)")
|
return
|
||||||
|
}
|
||||||
|
log.debug("VPN status did change (\(bundleId)): isEnabled=\(connection.manager.isEnabled), status=\(connection.status.rawValue)")
|
||||||
var notification = Notification(name: VPNNotification.didChangeStatus)
|
var notification = Notification(name: VPNNotification.didChangeStatus)
|
||||||
notification.vpnBundleIdentifier = bundleId
|
notification.vpnBundleIdentifier = bundleId
|
||||||
notification.vpnIsEnabled = connection.manager.isEnabled
|
notification.vpnIsEnabled = connection.manager.isEnabled
|
||||||
|
@ -265,6 +269,7 @@ public class NetworkExtensionVPN: VPN {
|
||||||
private extension NEVPNManager {
|
private extension NEVPNManager {
|
||||||
var tunnelBundleIdentifier: String? {
|
var tunnelBundleIdentifier: String? {
|
||||||
guard let proto = protocolConfiguration as? NETunnelProviderProtocol else {
|
guard let proto = protocolConfiguration as? NETunnelProviderProtocol else {
|
||||||
|
log.warning("No bundle identifier found because protocolConfiguration is not NETunnelProviderProtocol (\(type(of: protocolConfiguration))")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return proto.providerBundleIdentifier
|
return proto.providerBundleIdentifier
|
||||||
|
|
Loading…
Reference in New Issue