diff --git a/Library/Package.resolved b/Library/Package.resolved index 22cd3209..4fc71ea7 100644 --- a/Library/Package.resolved +++ b/Library/Package.resolved @@ -41,7 +41,7 @@ "kind" : "remoteSourceControl", "location" : "git@github.com:passepartoutvpn/passepartoutkit-source", "state" : { - "revision" : "d033e4431a24c7a7559464ef27036af9994647f2" + "revision" : "ee6d15d4776bb1f7cf13aa22c07ef98abb9d6c12" } }, { diff --git a/Library/Package.swift b/Library/Package.swift index 1611be44..423e66a8 100644 --- a/Library/Package.swift +++ b/Library/Package.swift @@ -65,7 +65,7 @@ let package = Package( ], dependencies: [ // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", from: "0.12.0"), - .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "d033e4431a24c7a7559464ef27036af9994647f2"), + .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source", revision: "ee6d15d4776bb1f7cf13aa22c07ef98abb9d6c12"), // .package(path: "../../passepartoutkit-source"), .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", from: "0.9.1"), // .package(url: "git@github.com:passepartoutvpn/passepartoutkit-source-openvpn-openssl", revision: "031863a1cd683962a7dfe68e20b91fa820a1ecce"), diff --git a/Library/Sources/CommonLibrary/Domain/EditableProfile.swift b/Library/Sources/CommonLibrary/Domain/EditableProfile.swift index 33809e0e..ffd53dda 100644 --- a/Library/Sources/CommonLibrary/Domain/EditableProfile.swift +++ b/Library/Sources/CommonLibrary/Domain/EditableProfile.swift @@ -37,7 +37,7 @@ public struct EditableProfile: MutableProfileType { public var modulesMetadata: [UUID: ModuleMetadata]? - public var userInfo: [String: AnyHashable]? + public var userInfo: AnyHashable? public init( id: UUID = UUID(), @@ -45,7 +45,7 @@ public struct EditableProfile: MutableProfileType { modules: [any ModuleBuilder] = [], activeModulesIds: Set = [], modulesMetadata: [UUID: ModuleMetadata]? = nil, - userInfo: [String: AnyHashable]? = nil + userInfo: AnyHashable? = nil ) { self.id = id self.name = name diff --git a/Library/Sources/CommonLibrary/Domain/ProfileAttributes.swift b/Library/Sources/CommonLibrary/Domain/ProfileAttributes.swift index dad2a7ab..61b6da66 100644 --- a/Library/Sources/CommonLibrary/Domain/ProfileAttributes.swift +++ b/Library/Sources/CommonLibrary/Domain/ProfileAttributes.swift @@ -69,17 +69,7 @@ extension ProfileAttributes: CustomDebugStringConvertible { // MARK: - UserInfoCodable extension ProfileAttributes: UserInfoCodable { - public var userInfo: [String: AnyHashable]? { - do { - let data = try JSONEncoder().encode(self) - return try JSONSerialization.jsonObject(with: data) as? [String: AnyHashable] ?? [:] - } catch { - pp_log(.App.profiles, .error, "Unable to encode ProfileAttributes to dictionary: \(error)") - return [:] - } - } - - public init?(userInfo: [String: AnyHashable]?) { + public init?(userInfo: AnyHashable?) { do { let data = try JSONSerialization.data(withJSONObject: userInfo ?? [:]) self = try JSONDecoder().decode(ProfileAttributes.self, from: data) @@ -88,6 +78,16 @@ extension ProfileAttributes: UserInfoCodable { return nil } } + + public var userInfo: AnyHashable? { + do { + let data = try JSONEncoder().encode(self) + return try JSONSerialization.jsonObject(with: data) as? AnyHashable + } catch { + pp_log(.App.profiles, .error, "Unable to encode ProfileAttributes to dictionary: \(error)") + return nil + } + } } extension Profile { diff --git a/Passepartout/Tunnel/PacketTunnelProvider.swift b/Passepartout/Tunnel/PacketTunnelProvider.swift index 586612f0..06441516 100644 --- a/Passepartout/Tunnel/PacketTunnelProvider.swift +++ b/Passepartout/Tunnel/PacketTunnelProvider.swift @@ -41,10 +41,16 @@ final class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable { provider: self, decoder: Registry.sharedProtocolCoder, registry: .shared, - environment: .shared + environment: .shared, + profileBlock: { + $0 + } ) - try await checkEligibility(of: fwd!.profile, environment: .shared) - try await fwd?.startTunnel(options: options) + guard let fwd else { + fatalError("NEPTPForwarder nil without throwing error?") + } + try await checkEligibility(of: fwd.profile, environment: .shared) + try await fwd.startTunnel(options: options) } catch { pp_log(.app, .fault, "Unable to start tunnel: \(error)") PassepartoutConfiguration.shared.flushLog()