mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
fix(apple): Load tunnel manager after creating it (#7593)
When launching Firezone for the first time, the VPN profile doesn't exist. We prompt the user to create it with "Grant VPN Permission", but then we fail to reload it, which initializes the tunnelManager instance variables properly and binds observers. The result of this was that we failed to react to VPN status changes on the first launch of Firezone. This can (and should be) refactored to be cleaner, but that is out of scope for this PR and will be saved for #6554. Refs #7579
This commit is contained in:
@@ -124,7 +124,7 @@ public class TunnelManager {
|
||||
private let bundleDescription = "Firezone"
|
||||
|
||||
// Initialize and save a new VPN profile in system Preferences
|
||||
func create() async throws -> Settings {
|
||||
func create() async throws {
|
||||
let protocolConfiguration = NETunnelProviderProtocol()
|
||||
let manager = NETunnelProviderManager()
|
||||
let settings = Settings.defaultValue
|
||||
@@ -144,8 +144,6 @@ public class TunnelManager {
|
||||
|
||||
await statusChangeHandler?(manager.connection.status)
|
||||
self.manager = manager
|
||||
|
||||
return settings
|
||||
}
|
||||
|
||||
func load(callback: @escaping (NEVPNStatus, Settings?, String?) -> Void) {
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class Store: ObservableObject {
|
||||
self.sessionNotification = SessionNotification()
|
||||
|
||||
initNotifications()
|
||||
initTunnelManager()
|
||||
loadTunnelManager()
|
||||
}
|
||||
|
||||
public func internetResourceEnabled() -> Bool {
|
||||
@@ -62,7 +62,7 @@ public final class Store: ObservableObject {
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
private func initTunnelManager() {
|
||||
private func loadTunnelManager() {
|
||||
// Subscribe to status updates from the tunnel manager
|
||||
TunnelManager.shared.statusChangeHandler = handleVPNStatusChange
|
||||
|
||||
@@ -94,9 +94,14 @@ public final class Store: ObservableObject {
|
||||
}
|
||||
|
||||
func createVPNProfile() {
|
||||
DispatchQueue.main.async {
|
||||
Task {
|
||||
self.settings = try await TunnelManager.shared.create()
|
||||
Task {
|
||||
try await TunnelManager.shared.create()
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self else { return }
|
||||
|
||||
// Load the new settings and bind observers
|
||||
self.loadTunnelManager()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ export default function Apple() {
|
||||
>
|
||||
{/* When you cut a release, remove any solved issues from the "known issues" lists over in `client-apps`. This must not be done when the issue's PR merges. */}
|
||||
<Unreleased>
|
||||
<ChangeItem pull="7593">
|
||||
Fixes a bug where the VPN status would not properly update upon the
|
||||
first launch of the app.
|
||||
</ChangeItem>
|
||||
<ChangeItem pull="7334">
|
||||
Fixes an issue where symmetric NATs would generate unnecessary
|
||||
candidate for hole-punching.
|
||||
|
||||
Reference in New Issue
Block a user