Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Skip notifications without a bundle identifier
Browse files Browse the repository at this point in the history
Would raise fatalError in notification getter.
  • Loading branch information
keeshux committed Dec 27, 2023
1 parent 6101e92 commit 92bc00e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Sources/TunnelKitManager/NetworkExtensionVPN.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ public class NetworkExtensionVPN: VPN {
}

private func notifyReinstall(_ manager: NETunnelProviderManager) {
let bundleId = manager.tunnelBundleIdentifier
log.debug("VPN did reinstall (\(bundleId ?? "?")): isEnabled=\(manager.isEnabled)")
guard let bundleId = manager.tunnelBundleIdentifier else {
return
}
log.debug("VPN did reinstall (\(bundleId)): isEnabled=\(manager.isEnabled)")

var notification = Notification(name: VPNNotification.didReinstall)
notification.vpnBundleIdentifier = bundleId
Expand All @@ -242,8 +244,10 @@ public class NetworkExtensionVPN: VPN {
log.verbose("Ignoring VPN notification from bogus manager")
return
}
let bundleId = connection.manager.tunnelBundleIdentifier
log.debug("VPN status did change (\(bundleId ?? "?")): isEnabled=\(connection.manager.isEnabled), status=\(connection.status.rawValue)")
guard let bundleId = connection.manager.tunnelBundleIdentifier else {
return
}
log.debug("VPN status did change (\(bundleId)): isEnabled=\(connection.manager.isEnabled), status=\(connection.status.rawValue)")
var notification = Notification(name: VPNNotification.didChangeStatus)
notification.vpnBundleIdentifier = bundleId
notification.vpnIsEnabled = connection.manager.isEnabled
Expand All @@ -265,6 +269,7 @@ public class NetworkExtensionVPN: VPN {
private extension NEVPNManager {
var tunnelBundleIdentifier: String? {
guard let proto = protocolConfiguration as? NETunnelProviderProtocol else {
log.warning("No bundle identifier found because protocolConfiguration is not NETunnelProviderProtocol (\(type(of: protocolConfiguration))")
return nil
}
return proto.providerBundleIdentifier
Expand Down

0 comments on commit 92bc00e

Please sign in to comment.