From 70a88b70916c313bb6673472481b908f4c20eaaa Mon Sep 17 00:00:00 2001 From: Jamil Date: Mon, 6 Jan 2025 00:13:48 -0800 Subject: [PATCH] fix(apple): Move status observer setup to `init()` (#7673) This is a very minor regression caused by #7555. We didn't bind the status update observer until after the VPN profile was created. In practice this didn't cause an issue because the status never changes until a VPN profile is created, but still thought it's good to fix. The JSON encoder is now configured in the `init()` as well like any other instance variable should be. --- .../Sources/FirezoneKit/Managers/TunnelManager.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/swift/apple/FirezoneKit/Sources/FirezoneKit/Managers/TunnelManager.swift b/swift/apple/FirezoneKit/Sources/FirezoneKit/Managers/TunnelManager.swift index 0a6c7baab..58556bf13 100644 --- a/swift/apple/FirezoneKit/Sources/FirezoneKit/Managers/TunnelManager.swift +++ b/swift/apple/FirezoneKit/Sources/FirezoneKit/Managers/TunnelManager.swift @@ -139,6 +139,13 @@ public class TunnelManager { public static let bundleIdentifier: String = "\(Bundle.main.bundleIdentifier!).network-extension" private let bundleDescription = "Firezone" + init() { + encoder.outputFormat = .binary + + // Hook up status updates + setupTunnelObservers() + } + // Initialize and save a new VPN profile in system Preferences func create() async throws { let protocolConfiguration = NETunnelProviderProtocol() @@ -150,7 +157,6 @@ public class TunnelManager { protocolConfiguration.serverAddress = settings.apiURL manager.localizedDescription = bundleDescription manager.protocolConfiguration = protocolConfiguration - encoder.outputFormat = .binary // Save the new VPN profile to System Preferences and reload it, // which should update our status from invalid -> disconnected. @@ -203,9 +209,6 @@ public class TunnelManager { } } - // Hook up status updates - setupTunnelObservers() - // If no tunnel configuration was found, update state to // prompt user to create one. if manager == nil {