From 9769a151db243db26a3ae41c40f25b4d7c9a8115 Mon Sep 17 00:00:00 2001 From: Davide Date: Sat, 12 Oct 2024 13:19:46 +0200 Subject: [PATCH] Provider configuration is persisted into module (#730) When e.g. a OpenVPNModule is created without a configuration and a provider/server is then selected, the ProfileProcessor class serializes the profile with the provider configuration injected. When the module is re-edited, we can see the provider server configuration in the module after selecting "None" as provider. Instead, validate the provider modules in ProfileProcessor, but generate the provider configuration on the fly in the tunnel. --- .../xcshareddata/swiftpm/Package.resolved | 3 +-- Passepartout/Library/Package.swift | 4 ++-- Passepartout/Shared/Shared+App.swift | 7 ++++--- Passepartout/Tunnel/PacketTunnelProvider.swift | 13 +++++++------ 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 4e2003bb..d1bbfa6e 100644 --- a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -41,8 +41,7 @@ "kind" : "remoteSourceControl", "location" : "git@github.com:passepartoutvpn/passepartoutkit-source", "state" : { - "revision" : "126392d2614c9d0ffe2aa2d96f6c5509221b8481", - "version" : "0.9.0" + "revision" : "0bfd4578b71a905584cdd5c9c39ab3087521af78" } }, { diff --git a/Passepartout/Library/Package.swift b/Passepartout/Library/Package.swift index 6424430e..1bdabded 100644 --- a/Passepartout/Library/Package.swift +++ b/Passepartout/Library/Package.swift @@ -27,8 +27,8 @@ let package = Package( ) ], dependencies: [ - .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"), -// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "bec0635fe047e09c8b6c894d103ab8dd741b8340"), +// .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.9.0"), + .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "0bfd4578b71a905584cdd5c9c39ab3087521af78"), // .package(path: "../../../passepartoutkit-source"), .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.8.0"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"), diff --git a/Passepartout/Shared/Shared+App.swift b/Passepartout/Shared/Shared+App.swift index ec4060be..b6747de0 100644 --- a/Passepartout/Shared/Shared+App.swift +++ b/Passepartout/Shared/Shared+App.swift @@ -136,13 +136,14 @@ extension ProfileProcessor { } } - let processed = try builder.tryBuild() + let profile = try builder.tryBuild() do { - return try processed.withProviderModules() + _ = try profile.withProviderModules() + return profile } catch { // FIXME: #703, alert unable to build provider server pp_log(.app, .error, "Unable to inject provider modules: \(error)") - return processed + throw error } } } diff --git a/Passepartout/Tunnel/PacketTunnelProvider.swift b/Passepartout/Tunnel/PacketTunnelProvider.swift index 6287f926..96db2188 100644 --- a/Passepartout/Tunnel/PacketTunnelProvider.swift +++ b/Passepartout/Tunnel/PacketTunnelProvider.swift @@ -36,15 +36,16 @@ final class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable { parameters: Constants.shared.log, logsPrivateData: UserDefaults.appGroup.bool(forKey: AppPreference.logsPrivateData.key) ) - fwd = try await NEPTPForwarder( - provider: self, - decoder: Registry.sharedProtocolCoder, - registry: .shared, - environment: .shared - ) do { + fwd = try await NEPTPForwarder( + provider: self, + decoder: Registry.sharedProtocolCoder, + registry: .shared, + environment: .shared + ) try await fwd?.startTunnel(options: options) } catch { + pp_log(.app, .fault, "Unable to start tunnel: \(error)") PassepartoutConfiguration.shared.flushLog() throw error }