mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-01-18 22:49:10 +00:00
Skip irrelevant notifications for VPN protocol
Based on tunnel bundle identifier in notification.
This commit is contained in:
parent
17198e53eb
commit
7ba41a0e73
@ -169,7 +169,9 @@ extension VPNManager {
|
||||
// MARK: Notifications
|
||||
|
||||
private func onVPNReinstall(_ notification: Notification) {
|
||||
currentBundleIdentifier = notification.vpnBundleIdentifier
|
||||
guard isRelevantNotification(notification) else {
|
||||
return
|
||||
}
|
||||
|
||||
vpnState.send(AtomicState(
|
||||
isEnabled: notification.vpnIsEnabled,
|
||||
@ -178,8 +180,11 @@ extension VPNManager {
|
||||
}
|
||||
|
||||
private func onVPNStatus(_ notification: Notification) {
|
||||
guard isRelevantNotification(notification) else {
|
||||
return
|
||||
}
|
||||
|
||||
var error: Error?
|
||||
currentBundleIdentifier = notification.vpnBundleIdentifier
|
||||
|
||||
switch notification.vpnStatus {
|
||||
case .connected:
|
||||
@ -211,6 +216,19 @@ extension VPNManager {
|
||||
currentState?.lastError = notification.vpnError
|
||||
}
|
||||
|
||||
private func isRelevantNotification(_ notification: Notification) -> Bool {
|
||||
guard let notificationTunnelIdentifier = notification.vpnBundleIdentifier else {
|
||||
return false
|
||||
}
|
||||
guard notificationTunnelIdentifier == currentBundleIdentifier else {
|
||||
pp_log.debug("Skipping not relevant notification from \(notificationTunnelIdentifier)")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// MARK: Data count
|
||||
|
||||
private func onDataCount(_: Date) {
|
||||
switch vpnState.value.vpnStatus {
|
||||
case .connected:
|
||||
|
Loading…
Reference in New Issue
Block a user