From 683617ddd4b273122ace96623ff57f5e137ba009 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Thu, 2 Jul 2020 19:14:17 +0200 Subject: [PATCH] Use active profile name in VPN configuration Rather than "Passepartout", as seen in device settings. --- CHANGELOG.md | 4 ++++ TunnelKit/Sources/Manager/StandardVPNProvider.swift | 1 + TunnelKit/Sources/Manager/VPNConfiguration.swift | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f1cfe8..77adfaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Use active profile name in VPN configuration (device settings). + ### Fixed - Incorrect tunnel bundle identifiers in Demo. [#176](https://github.com/passepartoutvpn/tunnelkit/issues/176) diff --git a/TunnelKit/Sources/Manager/StandardVPNProvider.swift b/TunnelKit/Sources/Manager/StandardVPNProvider.swift index fe76b6f..c960f1e 100644 --- a/TunnelKit/Sources/Manager/StandardVPNProvider.swift +++ b/TunnelKit/Sources/Manager/StandardVPNProvider.swift @@ -99,6 +99,7 @@ public class StandardVPNProvider: VPNProvider { return } self.manager = manager + manager.localizedDescription = configuration.title manager.protocolConfiguration = configuration.protocolConfiguration manager.onDemandRules = configuration.onDemandRules manager.isOnDemandEnabled = true diff --git a/TunnelKit/Sources/Manager/VPNConfiguration.swift b/TunnelKit/Sources/Manager/VPNConfiguration.swift index 16f42ea..0cfbb38 100644 --- a/TunnelKit/Sources/Manager/VPNConfiguration.swift +++ b/TunnelKit/Sources/Manager/VPNConfiguration.swift @@ -28,10 +28,16 @@ import NetworkExtension /// Generic marker for objects able to configure a `VPNProvider`. public protocol VPNConfiguration { + + /// The profile title in device settings. + var title: String { get } } /// A `VPNConfiguration` built on top of NetworkExtension entities. public struct NetworkExtensionVPNConfiguration: VPNConfiguration { + + /// :nodoc: + public var title: String /// The `NETunnelProviderProtocol` object embedding tunnel configuration. public let protocolConfiguration: NETunnelProviderProtocol @@ -40,7 +46,8 @@ public struct NetworkExtensionVPNConfiguration: VPNConfiguration { public let onDemandRules: [NEOnDemandRule] /// :nodoc: - public init(protocolConfiguration: NETunnelProviderProtocol, onDemandRules: [NEOnDemandRule]) { + public init(title: String, protocolConfiguration: NETunnelProviderProtocol, onDemandRules: [NEOnDemandRule]) { + self.title = title self.protocolConfiguration = protocolConfiguration self.onDemandRules = onDemandRules }