diff --git a/Passepartout/AppShared/Context/CoreContext.swift b/Passepartout/AppShared/Context/CoreContext.swift index 404084ff..a463095e 100644 --- a/Passepartout/AppShared/Context/CoreContext.swift +++ b/Passepartout/AppShared/Context/CoreContext.swift @@ -119,5 +119,10 @@ class CoreContext { profileManager.observeUpdates() vpnManager.observeUpdates() + + CoreConfiguration.masksPrivateData = vpnManager.masksPrivateData + vpnManager.didUpdatePreferences.sink { + CoreConfiguration.masksPrivateData = $0.masksPrivateData + }.store(in: &cancellables) } } diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/VPNManager+Configuration.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/VPNManager+Configuration.swift index 7ef17c78..55e86855 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/VPNManager+Configuration.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/VPNManager+Configuration.swift @@ -28,7 +28,7 @@ import PassepartoutCore import PassepartoutUtils extension VPNManager { - private var vpnPreferences: VPNPreferences { + var vpnPreferences: VPNPreferences { DefaultVPNPreferences( tunnelLogPath: tunnelLogPath, tunnelLogFormat: tunnelLogFormat, diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/VPNManager.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/VPNManager.swift index 4436d620..df07a9f4 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/VPNManager.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Managers/VPNManager.swift @@ -25,8 +25,6 @@ import Foundation import Combine -import TunnelKitCore -import TunnelKitManager import PassepartoutCore import PassepartoutProfiles import PassepartoutProviders @@ -55,6 +53,8 @@ public final class VPNManager: ObservableObject { public let currentState: ObservableVPNState + public let didUpdatePreferences = PassthroughSubject() + public private(set) var lastError: Error? { get { currentState.lastError @@ -88,8 +88,6 @@ public final class VPNManager: ObservableObject { isOnDemandRulesSupported = { true } currentState = ObservableVPNState() - - CoreConfiguration.masksPrivateData = masksPrivateData } func reinstate(_ configuration: VPNConfiguration) async { @@ -261,6 +259,7 @@ extension VPNManager { } set { store.setValue(newValue, forLocation: StoreKey.tunnelLogPath) + didUpdatePreferences.send(vpnPreferences) } } @@ -270,6 +269,7 @@ extension VPNManager { } set { store.setValue(newValue, forLocation: StoreKey.tunnelLogFormat) + didUpdatePreferences.send(vpnPreferences) } } @@ -279,8 +279,7 @@ extension VPNManager { } set { store.setValue(newValue, forLocation: StoreKey.masksPrivateData) - - CoreConfiguration.masksPrivateData = masksPrivateData + didUpdatePreferences.send(vpnPreferences) } } } diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNPreferences.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNPreferences.swift index bdc8785f..1d333ed4 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNPreferences.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Models/VPNPreferences.swift @@ -25,7 +25,7 @@ import Foundation -protocol VPNPreferences { +public protocol VPNPreferences { var tunnelLogPath: String? { get } var tunnelLogFormat: String? { get }