@@ -10,16 +10,29 @@ class OsStatus: Encodable {
1010 var internetAvailable : Bool = false
1111 var osVpnStatus : NEVPNStatus
1212 let srcVersion = sourceVersion ( )
13+ var strictLeakPrevention : Bool
1314 var updaterStatus = UpdaterStatus ( )
1415 var debugBundleStatus = DebugBundleStatus ( )
1516
16- init ( osVpnStatus: NEVPNStatus ) {
17+ init (
18+ strictLeakPrevention: Bool ,
19+ osVpnStatus: NEVPNStatus ,
20+ ) {
1721 self . osVpnStatus = osVpnStatus
22+ self . strictLeakPrevention = strictLeakPrevention
1823 }
1924
20- static func watchable( connection: NEVPNConnection ) -> WatchableValue < OsStatus > {
21- let notifications = NotificationCenter . default. notifications ( named: . NEVPNStatusDidChange, object: connection)
22- let w = WatchableValue ( OsStatus ( osVpnStatus: connection. status) )
25+ static func watchable(
26+ manager: NEVPNManager ,
27+ ) -> WatchableValue < OsStatus > {
28+ var lastIncludeAllNetworks = switch manager. protocolConfiguration {
29+ case let . some( proto) : proto. includeAllNetworks
30+ case nil : false // Report safe default.
31+ }
32+ let w = WatchableValue ( OsStatus (
33+ strictLeakPrevention: lastIncludeAllNetworks,
34+ osVpnStatus: manager. connection. status
35+ ) )
2336 Task {
2437 for await path in NWPathMonitor ( ) . stream ( ) {
2538 logger. info ( " NWPathMonitor event: \( path. debugDescription, privacy: . public) " )
@@ -29,16 +42,44 @@ class OsStatus: Encodable {
2942 }
3043 }
3144 }
45+
46+ let vpnConfigNotifications = NotificationCenter . default. notifications ( named: . NEVPNConfigurationChange, object: manager)
3247 Task {
33- for await _ in notifications {
34- let osVpnStatus = connection. status
48+ for await _ in vpnConfigNotifications {
49+ let includeAllNetworks : Bool
50+ if let proto = manager. protocolConfiguration {
51+ includeAllNetworks = proto. includeAllNetworks
52+ } else {
53+ logger. warning ( " NEVPNManager.protocolConfiguration is nil " )
54+ includeAllNetworks = false // Safe default
55+ }
56+
57+ logger. info ( " NEVPNConfigurationChangeNotification includeAllNetworks \( includeAllNetworks, privacy: . public) " )
58+
59+ if includeAllNetworks == lastIncludeAllNetworks {
60+ continue
61+ }
62+
63+ lastIncludeAllNetworks = includeAllNetworks
64+ _ = w. update { value in
65+ value. strictLeakPrevention = includeAllNetworks
66+ value. version = UUID ( )
67+ }
68+ }
69+ }
70+
71+ let vpnStatusNotifications = NotificationCenter . default. notifications ( named: . NEVPNStatusDidChange, object: manager. connection)
72+ Task {
73+ for await _ in vpnStatusNotifications {
74+ let osVpnStatus = manager. connection. status
3575 logger. info ( " NEVPNStatus event: \( osVpnStatus, privacy: . public) " )
3676 _ = w. update { value in
3777 value. osVpnStatus = osVpnStatus
3878 value. version = UUID ( )
3979 }
4080 }
4181 }
82+
4283 return w
4384 }
4485}
0 commit comments