Merge branch 'upgrade-tunnelkit-2.0'

This commit is contained in:
Davide De Rosa 2019-05-25 18:33:23 +02:00
commit c6c32430bc
34 changed files with 191 additions and 132 deletions

View File

@ -25,7 +25,7 @@
import TunnelKit
class PacketTunnelProvider: TunnelKitProvider {
class PacketTunnelProvider: OpenVPNTunnelProvider {
override func startTunnel(options: [String : NSObject]?, completionHandler: @escaping (Error?) -> Void) {
appVersion = "\(GroupConstants.App.name) \(GroupConstants.App.versionString)"
dnsTimeout = GroupConstants.VPN.dnsTimeout

View File

@ -8,7 +8,7 @@
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.algoritmico.Passepartout</string>
<string>group.$(CFG_GROUP_ID)</string>
</array>
</dict>
</plist>

View File

@ -106,11 +106,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
let passphraseCancelBlock = {
_ = try? FileManager.default.removeItem(at: url)
}
guard let parsingResult = ConfigurationParser.Result.from(url, withErrorAlertIn: target, passphrase: passphrase, passphraseBlock: passphraseBlock, passphraseCancelBlock: passphraseCancelBlock) else {
guard let parsingResult = OpenVPN.ConfigurationParser.Result.from(url, withErrorAlertIn: target, passphrase: passphrase, passphraseBlock: passphraseBlock, passphraseCancelBlock: passphraseCancelBlock) else {
return true
}
if let warning = parsingResult.warning {
ConfigurationParser.Result.alertImportWarning(url: url, in: target, withWarning: warning) {
OpenVPN.ConfigurationParser.Result.alertImportWarning(url: url, in: target, withWarning: warning) {
if $0 {
self.handleParsingResult(parsingResult, in: target)
} else {
@ -123,7 +123,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
return true
}
private func handleParsingResult(_ parsingResult: ConfigurationParser.Result, in target: UIViewController) {
private func handleParsingResult(_ parsingResult: OpenVPN.ConfigurationParser.Result, in target: UIViewController) {
// already presented: update parsed configuration
if let nav = target as? UINavigationController, let wizard = nav.topViewController as? WizardHostViewController {

View File

@ -0,0 +1,32 @@
//
// Config.xcconfig
// Passepartout
//
// Created by Davide De Rosa on 5/24/19.
// Copyright (c) 2019 Davide De Rosa. All rights reserved.
//
// https://github.com/passepartoutvpn
//
// This file is part of Passepartout.
//
// Passepartout is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Passepartout is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//
// Configuration settings file format documentation can be found at:
// https://help.apple.com/xcode/#/dev745c5c974
CFG_TEAM_ID = DTDYD63ZX9
CFG_APP_ID = com.algoritmico.ios.Passepartout
CFG_GROUP_ID = com.algoritmico.Passepartout
CFG_APPSTORE_ID = 1433648537

View File

@ -1,5 +1,5 @@
//
// ConfigurationParserResult+Alerts.swift
// OpenVPN.ConfigurationParserResult+Alerts.swift
// Passepartout-iOS
//
// Created by Davide De Rosa on 10/27/18.
@ -31,16 +31,16 @@ import Passepartout_Core
private let log = SwiftyBeaver.self
extension ConfigurationParser.Result {
extension OpenVPN.ConfigurationParser.Result {
static func from(_ url: URL, withErrorAlertIn viewController: UIViewController, passphrase: String?,
passphraseBlock: @escaping (String) -> Void, passphraseCancelBlock: (() -> Void)?) -> ConfigurationParser.Result? {
passphraseBlock: @escaping (String) -> Void, passphraseCancelBlock: (() -> Void)?) -> OpenVPN.ConfigurationParser.Result? {
let result: ConfigurationParser.Result
let result: OpenVPN.ConfigurationParser.Result
let fm = FileManager.default
log.debug("Parsing configuration URL: \(url)")
do {
result = try ConfigurationParser.parsed(fromURL: url, passphrase: passphrase)
result = try OpenVPN.ConfigurationParser.parsed(fromURL: url, passphrase: passphrase)
} catch let e as ConfigurationError {
switch e {
case .encryptionPassphrase, .unableToDecrypt(_):

View File

@ -92,7 +92,7 @@ class IssueReporter: NSObject {
}
if let url = configurationURL {
do {
let parsedFile = try ConfigurationParser.parsed(fromURL: url, returnsStripped: true)
let parsedFile = try OpenVPN.ConfigurationParser.parsed(fromURL: url, returnsStripped: true)
if let attachment = parsedFile.strippedLines?.joined(separator: "\n").data(using: .utf8) {
vc.addAttachmentData(attachment, mimeType: AppConstants.IssueReporter.MIME.configuration, fileName: AppConstants.IssueReporter.Filenames.configuration)
}

View File

@ -75,7 +75,7 @@ extension SettingTableViewCell {
accessoryType = .none
}
func applyVPN(_ theme: Theme, with vpnStatus: VPNStatus?, error: TunnelKitProvider.ProviderError?) {
func applyVPN(_ theme: Theme, with vpnStatus: VPNStatus?, error: OpenVPNTunnelProvider.ProviderError?) {
leftTextColor = theme.palette.primaryText
guard let vpnStatus = vpnStatus else {
rightText = L10n.Vpn.disabled

View File

@ -105,5 +105,12 @@
</dict>
</dict>
</array>
<key>com.algoritmico.Passepartout.config</key>
<dict>
<key>group_id</key>
<string>group.$(CFG_GROUP_ID)</string>
<key>appstore_id</key>
<string>$(CFG_APPSTORE_ID)</string>
</dict>
</dict>
</plist>

View File

@ -12,7 +12,7 @@
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.algoritmico.Passepartout</string>
<string>group.$(CFG_GROUP_ID)</string>
</array>
</dict>
</plist>

View File

@ -27,7 +27,7 @@ import Foundation
import TunnelKit
protocol ConfigurationModificationDelegate: class {
func configuration(didUpdate newConfiguration: SessionProxy.Configuration)
func configuration(didUpdate newConfiguration: OpenVPN.Configuration)
func configurationShouldReinstall()
}

View File

@ -35,9 +35,9 @@ class ConfigurationViewController: UIViewController, TableModelHost {
private lazy var itemRefresh = UIBarButtonItem(barButtonSystemItem: .refresh, target: self, action: #selector(refresh))
var initialConfiguration: SessionProxy.Configuration!
var initialConfiguration: OpenVPN.Configuration!
private lazy var configuration: SessionProxy.ConfigurationBuilder = initialConfiguration.builder()
private lazy var configuration: OpenVPN.ConfigurationBuilder = initialConfiguration.builder()
var originalConfigurationURL: URL?
@ -138,9 +138,9 @@ class ConfigurationViewController: UIViewController, TableModelHost {
log.warning("Resetting with no original configuration set? Bad table model?")
return
}
let parsingResult: ConfigurationParser.Result
let parsingResult: OpenVPN.ConfigurationParser.Result
do {
parsingResult = try ConfigurationParser.parsed(fromURL: originalURL)
parsingResult = try OpenVPN.ConfigurationParser.parsed(fromURL: originalURL)
} catch let e {
log.error("Could not parse original configuration: \(e)")
return
@ -373,7 +373,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
switch model.row(at: indexPath) {
case .cipher:
let vc = OptionViewController<SessionProxy.Cipher>()
let vc = OptionViewController<OpenVPN.Cipher>()
vc.title = settingCell?.leftText
vc.options = [.aes128cbc, .aes192cbc, .aes256cbc, .aes128gcm, .aes192gcm, .aes256gcm]
vc.selectedOption = configuration.cipher
@ -385,7 +385,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
navigationController?.pushViewController(vc, animated: true)
case .digest:
let vc = OptionViewController<SessionProxy.Digest>()
let vc = OptionViewController<OpenVPN.Digest>()
vc.title = settingCell?.leftText
vc.options = [.sha1, .sha224, .sha256, .sha384, .sha512]
vc.selectedOption = configuration.digest
@ -397,7 +397,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
navigationController?.pushViewController(vc, animated: true)
case .compressionFraming:
let vc = OptionViewController<SessionProxy.CompressionFraming>()
let vc = OptionViewController<OpenVPN.CompressionFraming>()
vc.title = settingCell?.leftText
vc.options = [.disabled, .compLZO, .compress]
vc.selectedOption = configuration.compressionFraming ?? .disabled
@ -416,7 +416,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
return
}
let vc = OptionViewController<SessionProxy.CompressionAlgorithm>()
let vc = OptionViewController<OpenVPN.CompressionAlgorithm>()
vc.title = settingCell?.leftText
vc.options = [.disabled, .LZO]
vc.selectedOption = configuration.compressionAlgorithm ?? .disabled
@ -449,7 +449,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
// MARK: -
private extension SessionProxy.CompressionFraming {
private extension OpenVPN.CompressionFraming {
var cellDescription: String {
let V = L10n.Configuration.Cells.self
switch self {
@ -465,7 +465,7 @@ private extension SessionProxy.CompressionFraming {
}
}
private extension SessionProxy.CompressionAlgorithm {
private extension OpenVPN.CompressionAlgorithm {
var cellDescription: String {
let V = L10n.Configuration.Cells.self
switch self {

View File

@ -33,7 +33,7 @@ private let log = SwiftyBeaver.self
class ImportedHostsViewController: UITableViewController {
private lazy var pendingConfigurationURLs = TransientStore.shared.service.pendingConfigurationURLs().sortedCaseInsensitive()
private var parsingResult: ConfigurationParser.Result?
private var parsingResult: OpenVPN.ConfigurationParser.Result?
override func viewDidLoad() {
super.viewDidLoad()
@ -88,7 +88,7 @@ class ImportedHostsViewController: UITableViewController {
}
self.perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier, sender: cell)
}
guard let parsingResult = ConfigurationParser.Result.from(url, withErrorAlertIn: self, passphrase: passphrase, passphraseBlock: passphraseBlock, passphraseCancelBlock: nil) else {
guard let parsingResult = OpenVPN.ConfigurationParser.Result.from(url, withErrorAlertIn: self, passphrase: passphrase, passphraseBlock: passphraseBlock, passphraseCancelBlock: nil) else {
deselectSelectedRow()
return false
}
@ -96,7 +96,7 @@ class ImportedHostsViewController: UITableViewController {
// postpone segue until alert dismissal
if let warning = parsingResult.warning {
ConfigurationParser.Result.alertImportWarning(url: url, in: self, withWarning: warning) {
OpenVPN.ConfigurationParser.Result.alertImportWarning(url: url, in: self, withWarning: warning) {
self.deselectSelectedRow()
if $0 {
self.perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier)

View File

@ -319,7 +319,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
}
private func writeReview() {
let url = AppConstants.URLs.review(withId: GroupConstants.App.appId)
let url = AppConstants.URLs.review(withId: AppConstants.App.appStoreId)
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

View File

@ -37,7 +37,7 @@ class WizardHostViewController: UITableViewController, TableModelHost {
return TransientStore.shared.service.ids(forContext: .host).sortedCaseInsensitive()
}()
var parsingResult: ConfigurationParser.Result? {
var parsingResult: OpenVPN.ConfigurationParser.Result? {
didSet {
useSuggestedTitle()
}
@ -104,7 +104,7 @@ class WizardHostViewController: UITableViewController, TableModelHost {
}
let profile = HostConnectionProfile(title: enteredTitle, hostname: hostname)
let builder = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: result.configuration)
let builder = OpenVPNTunnelProvider.ConfigurationBuilder(sessionConfiguration: result.configuration)
profile.parameters = builder.build()
let service = TransientStore.shared.service

View File

@ -1217,7 +1217,7 @@ extension ServiceViewController: TrustedNetworksModelDelegate {
// MARK: -
extension ServiceViewController: ConfigurationModificationDelegate {
func configuration(didUpdate newConfiguration: SessionProxy.Configuration) {
func configuration(didUpdate newConfiguration: OpenVPN.Configuration) {
if let hostProfile = profile as? HostConnectionProfile {
var builder = hostProfile.parameters.builder()
builder.sessionConfiguration = newConfiguration

View File

@ -185,6 +185,7 @@
0E158AD920E11B0B00C85A82 /* EndpointViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EndpointViewController.swift; sourceTree = "<group>"; };
0E1D72B1213BFFCF00BA1586 /* ProviderPresetViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProviderPresetViewController.swift; sourceTree = "<group>"; };
0E1D72B3213C118500BA1586 /* ConfigurationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationViewController.swift; sourceTree = "<group>"; };
0E23B4A12298559800304C30 /* Config.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Config.xcconfig; sourceTree = "<group>"; };
0E242735225944060064A1A3 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Intents.strings; sourceTree = "<group>"; };
0E24273B225950450064A1A3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/About.storyboard; sourceTree = "<group>"; };
0E24273F225951B00064A1A3 /* InApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InApp.swift; sourceTree = "<group>"; };
@ -461,6 +462,7 @@
0E1066CA20E0F85C004F98B7 /* Cells */,
0ECEE44C20E1120F00A6BB43 /* Tables */,
0EDE8DF120C93ED8004C739C /* Scenes */,
0E23B4A12298559800304C30 /* Config.xcconfig */,
0EDE8DE220C86A13004C739C /* Passepartout.entitlements */,
0E57F63B20C83FC5008323CF /* AppDelegate.swift */,
0E24273C225950450064A1A3 /* About.storyboard */,
@ -1341,6 +1343,7 @@
};
0E57F65320C83FC7008323CF /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 0E23B4A12298559800304C30 /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
@ -1407,6 +1410,7 @@
};
0E57F65420C83FC7008323CF /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 0E23B4A12298559800304C30 /* Config.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
@ -1480,7 +1484,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.Passepartout;
PRODUCT_BUNDLE_IDENTIFIER = "$(CFG_APP_ID)";
PRODUCT_NAME = Passepartout;
PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@ -1504,7 +1508,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.Passepartout;
PRODUCT_BUNDLE_IDENTIFIER = "$(CFG_APP_ID)";
PRODUCT_NAME = Passepartout;
PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout";
SWIFT_VERSION = 5.0;
@ -1527,7 +1531,7 @@
"@executable_path/../../Frameworks",
);
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.Passepartout.Tunnel;
PRODUCT_BUNDLE_IDENTIFIER = "$(CFG_APP_ID).Tunnel";
PRODUCT_NAME = "Passepartout-Tunnel";
PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout.Tunnel";
SKIP_INSTALL = YES;
@ -1550,7 +1554,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.algoritmico.ios.Passepartout.Tunnel;
PRODUCT_BUNDLE_IDENTIFIER = "$(CFG_APP_ID).Tunnel";
PRODUCT_NAME = "Passepartout-Tunnel";
PROVISIONING_PROFILE_SPECIFIER = "match Development com.algoritmico.ios.Passepartout.Tunnel";
SKIP_INSTALL = YES;

View File

@ -28,6 +28,22 @@ import TunnelKit
import SwiftyBeaver
public class AppConstants {
public class App {
public static let appStoreId: String = {
guard let identifier = GroupConstants.App.config["appstore_id"] as? String else {
fatalError("Missing appstore_id from Info.plist config")
}
return identifier
}()
public static let tunnelBundleId: String = {
guard let identifier = Bundle.main.infoDictionary?[kCFBundleIdentifierKey as String] as? String else {
fatalError("Missing kCFBundleIdentifierKey from Info.plist")
}
return "\(identifier).Tunnel"
}()
}
public class Flags {
public static let isBeta = false
}

View File

@ -39,23 +39,23 @@ public class GroupConstants {
public static let buildNumber = Int(Bundle.main.infoDictionary![kCFBundleVersionKey as String] as! String)!
public static let versionString = "\(versionNumber) (\(buildNumber))"
public static let teamId = "DTDYD63ZX9"
public static let appId = "1433648537"
public static let config: [String: Any] = {
guard let cfg = Bundle.main.infoDictionary?["com.algoritmico.Passepartout.config"] as? [String: Any] else {
fatalError("Missing app config from Info.plist")
}
return cfg
}()
#if os(iOS)
public static let appGroup = "group.com.algoritmico.Passepartout"
public static let tunnelIdentifier = "com.algoritmico.ios.Passepartout.Tunnel"
#else
public static let appGroup = "\(teamId).group.com.algoritmico.Passepartout"
public static let tunnelIdentifier = "com.algoritmico.macos.Passepartout.Tunnel"
#endif
public static let groupId: String = {
guard let identifier = config["group_id"] as? String else {
fatalError("Missing group_id from Info.plist config")
}
return identifier
}()
private static var containerURL: URL {
guard let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroup) else {
guard let url = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: groupId) else {
print("Unable to access App Group container")
return FileManager.default.userURL(for: .documentDirectory, appending: nil)
}

View File

@ -46,7 +46,7 @@ public protocol ConnectionProfile: class, EndpointDataSource, CustomStringConver
var manualNetworkSettings: ProfileNetworkSettings? { get set }
func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration
func generate(from configuration: OpenVPNTunnelProvider.Configuration, preferences: Preferences) throws -> OpenVPNTunnelProvider.Configuration
func with(newId: String) -> ConnectionProfile
}

View File

@ -89,7 +89,7 @@ public class ConnectionService: Codable {
private let keychain: Keychain
public var baseConfiguration: TunnelKitProvider.Configuration
public var baseConfiguration: OpenVPNTunnelProvider.Configuration
private var cache: [ProfileKey: ConnectionProfile]
@ -124,7 +124,7 @@ public class ConnectionService: Codable {
public weak var delegate: ConnectionServiceDelegate?
public init(withAppGroup appGroup: String, baseConfiguration: TunnelKitProvider.Configuration) {
public init(withAppGroup appGroup: String, baseConfiguration: OpenVPNTunnelProvider.Configuration) {
guard let defaults = UserDefaults(suiteName: appGroup) else {
fatalError("No entitlements for group '\(appGroup)'")
}
@ -157,7 +157,7 @@ public class ConnectionService: Codable {
self.defaults = defaults
keychain = Keychain(group: appGroup)
baseConfiguration = try container.decode(TunnelKitProvider.Configuration.self, forKey: .baseConfiguration)
baseConfiguration = try container.decode(OpenVPNTunnelProvider.Configuration.self, forKey: .baseConfiguration)
activeProfileKey = try container.decodeIfPresent(ProfileKey.self, forKey: .activeProfileKey)
preferences = try container.decode(EditablePreferences.self, forKey: .preferences)
@ -281,20 +281,10 @@ public class ConnectionService: Codable {
profile = providerProfile
case .host:
let hostProfile = try decoder.decode(HostConnectionProfile.self, from: data)
// XXX: migrate old endpointProtocols
if hostProfile.parameters.sessionConfiguration.endpointProtocols == nil {
var sessionBuilder = hostProfile.parameters.sessionConfiguration.builder()
sessionBuilder.endpointProtocols = hostProfile.parameters.endpointProtocols
var parametersBuilder = hostProfile.parameters.builder()
parametersBuilder.sessionConfiguration = sessionBuilder.build()
hostProfile.parameters = parametersBuilder.build()
}
// XXX: re-read routing policies for
profile = hostProfile
// let hostProfile = try decoder.decode(HostConnectionProfile.self, from: data)
//
// profile = hostProfile
break
}
cache[key] = profile
} catch let e {
@ -350,8 +340,8 @@ public class ConnectionService: Codable {
}
// can fail due to passphrase (migration is non-interactive)
if let result = try? ConfigurationParser.parsed(fromURL: url) {
host.parameters = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: result.configuration).build()
if let result = try? OpenVPN.ConfigurationParser.parsed(fromURL: url) {
host.parameters = OpenVPNTunnelProvider.ConfigurationBuilder(sessionConfiguration: result.configuration).build()
} else {
// fall back to the safer option
@ -549,7 +539,7 @@ public class ConnectionService: Codable {
}
let protocolConfiguration = try cfg.generatedTunnelProtocol(
withBundleIdentifier: GroupConstants.App.tunnelIdentifier,
withBundleIdentifier: AppConstants.App.tunnelBundleId,
appGroup: appGroup,
credentials: creds
)
@ -602,7 +592,7 @@ public class ConnectionService: Codable {
try? FileManager.default.removeItem(at: url)
}
public var vpnLastError: TunnelKitProvider.ProviderError? {
public var vpnLastError: OpenVPNTunnelProvider.ProviderError? {
return baseConfiguration.lastError(in: appGroup)
}

View File

@ -26,7 +26,7 @@
import Foundation
import TunnelKit
public typealias Credentials = SessionProxy.Credentials
public typealias Credentials = OpenVPN.Credentials
public extension Credentials {
var isEmpty: Bool {

View File

@ -49,7 +49,7 @@ public class ProfileNetworkChoices: Codable {
}
public class ProfileNetworkSettings: Codable, CustomStringConvertible {
public var gatewayPolicies: [SessionProxy.RoutingPolicy]?
public var gatewayPolicies: [OpenVPN.RoutingPolicy]?
public var dnsServers: [String]?
@ -72,7 +72,7 @@ public class ProfileNetworkSettings: Codable, CustomStringConvertible {
gatewayPolicies = [.IPv4, .IPv6]
}
public init(from configuration: SessionProxy.Configuration) {
public init(from configuration: OpenVPN.Configuration) {
gatewayPolicies = configuration.routingPolicies
dnsDomainName = configuration.searchDomain
dnsServers = configuration.dnsServers
@ -114,7 +114,7 @@ public class ProfileNetworkSettings: Codable, CustomStringConvertible {
}
}
extension SessionProxy.ConfigurationBuilder {
extension OpenVPN.ConfigurationBuilder {
public mutating func applyGateway(from choices: ProfileNetworkChoices, settings: ProfileNetworkSettings) {
switch choices.gateway {
case .client:

View File

@ -31,13 +31,13 @@ public class HostConnectionProfile: ConnectionProfile, Codable, Equatable {
public let hostname: String
public var parameters: TunnelKitProvider.Configuration
public var parameters: OpenVPNTunnelProvider.Configuration
public init(title: String, hostname: String) {
self.title = title
self.hostname = hostname
let sessionConfiguration = SessionProxy.ConfigurationBuilder().build()
parameters = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: sessionConfiguration).build()
let sessionConfiguration = OpenVPN.ConfigurationBuilder().build()
parameters = OpenVPNTunnelProvider.ConfigurationBuilder(sessionConfiguration: sessionConfiguration).build()
}
// MARK: ConnectionProfile
@ -58,7 +58,7 @@ public class HostConnectionProfile: ConnectionProfile, Codable, Equatable {
public var manualNetworkSettings: ProfileNetworkSettings?
public func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration {
public func generate(from configuration: OpenVPNTunnelProvider.Configuration, preferences: Preferences) throws -> OpenVPNTunnelProvider.Configuration {
guard let endpointProtocols = parameters.sessionConfiguration.endpointProtocols, !endpointProtocols.isEmpty else {
preconditionFailure("No endpointProtocols")
}

View File

@ -39,7 +39,7 @@ public class PlaceholderConnectionProfile: ConnectionProfile {
public var manualNetworkSettings: ProfileNetworkSettings?
public func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration {
public func generate(from configuration: OpenVPNTunnelProvider.Configuration, preferences: Preferences) throws -> OpenVPNTunnelProvider.Configuration {
fatalError("Generating configuration from a PlaceholderConnectionProfile")
}

View File

@ -114,7 +114,7 @@ public class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
return true
}
public func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration {
public func generate(from configuration: OpenVPNTunnelProvider.Configuration, preferences: Preferences) throws -> OpenVPNTunnelProvider.Configuration {
guard let pool = pool else {
preconditionFailure("Nil pool?")
}

View File

@ -26,14 +26,14 @@
import Foundation
import TunnelKit
public extension SessionProxy.ConfigurationBuilder {
// mutating func copyCommunication(from other: SessionProxy.ConfigurationBuilder) {
public extension OpenVPN.ConfigurationBuilder {
// mutating func copyCommunication(from other: OpenVPN.ConfigurationBuilder) {
// cipher = other.cipher
// digest = other.digest
// compressionFraming = other.compressionFraming
// }
func canCommunicate(with other: SessionProxy.Configuration) -> Bool {
func canCommunicate(with other: OpenVPN.Configuration) -> Bool {
return
(cipher == other.cipher) &&
((digest == other.digest) || fallbackCipher.embedsDigest) &&

View File

@ -75,9 +75,9 @@ public class TransientStore {
}
}
public static var baseVPNConfiguration: TunnelKitProvider.ConfigurationBuilder {
let sessionBuilder = SessionProxy.ConfigurationBuilder()
var builder = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
public static var baseVPNConfiguration: OpenVPNTunnelProvider.ConfigurationBuilder {
let sessionBuilder = OpenVPN.ConfigurationBuilder()
var builder = OpenVPNTunnelProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
builder.mtu = 1250
builder.shouldDebug = true
// builder.debugLogFormat = "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M"
@ -119,7 +119,7 @@ public class TransientStore {
} catch let e {
log.error("Could not decode service: \(e)")
service = ConnectionService(
withAppGroup: GroupConstants.App.appGroup,
withAppGroup: GroupConstants.App.groupId,
baseConfiguration: cfg
)

View File

@ -26,7 +26,7 @@
import Foundation
import TunnelKit
// supports a subset of TunnelKitProvider.Configuration
// supports a subset of OpenVPNTunnelProvider.Configuration
// ignores new JSON keys
public struct InfrastructurePreset: Codable {
@ -90,7 +90,7 @@ public struct InfrastructurePreset: Codable {
public let comment: String
public let configuration: TunnelKitProvider.Configuration
public let configuration: OpenVPNTunnelProvider.Configuration
public let external: [ExternalKey: String]?
@ -107,13 +107,13 @@ public struct InfrastructurePreset: Codable {
case .ca:
let filename = pattern.replacingOccurrences(of: "${id}", with: pool.id)
let caURL = baseURL.appendingPathComponent(filename)
return CryptoContainer(pem: try String(contentsOf: caURL))
return OpenVPN.CryptoContainer(pem: try String(contentsOf: caURL))
case .wrapKeyData:
let filename = pattern.replacingOccurrences(of: "${id}", with: pool.id)
let tlsKeyURL = baseURL.appendingPathComponent(filename)
let file = try String(contentsOf: tlsKeyURL)
return StaticKey(file: file, direction: .client)
return OpenVPN.StaticKey(file: file, direction: .client)
case .hostname:
return pattern.replacingOccurrences(of: "${id}", with: pool.id)
@ -124,19 +124,19 @@ public struct InfrastructurePreset: Codable {
return nil
}
public func injectExternalConfiguration(_ configuration: inout TunnelKitProvider.ConfigurationBuilder, with infrastructureName: Infrastructure.Name, pool: Pool) throws {
public func injectExternalConfiguration(_ configuration: inout OpenVPNTunnelProvider.ConfigurationBuilder, with infrastructureName: Infrastructure.Name, pool: Pool) throws {
guard let external = external, !external.isEmpty else {
return
}
var sessionBuilder = configuration.sessionConfiguration.builder()
if let _ = external[.ca] {
sessionBuilder.ca = try externalConfiguration(forKey: .ca, infrastructureName: infrastructureName, pool: pool) as? CryptoContainer
sessionBuilder.ca = try externalConfiguration(forKey: .ca, infrastructureName: infrastructureName, pool: pool) as? OpenVPN.CryptoContainer
}
if let _ = external[.wrapKeyData] {
if let dummyWrap = sessionBuilder.tlsWrap {
if let staticKey = try externalConfiguration(forKey: .wrapKeyData, infrastructureName: infrastructureName, pool: pool) as? StaticKey {
sessionBuilder.tlsWrap = SessionProxy.TLSWrap(strategy: dummyWrap.strategy, key: staticKey)
if let staticKey = try externalConfiguration(forKey: .wrapKeyData, infrastructureName: infrastructureName, pool: pool) as? OpenVPN.StaticKey {
sessionBuilder.tlsWrap = OpenVPN.TLSWrap(strategy: dummyWrap.strategy, key: staticKey)
}
}
}
@ -168,17 +168,17 @@ public struct InfrastructurePreset: Codable {
let cfgContainer = try container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration)
var sessionBuilder = SessionProxy.ConfigurationBuilder()
sessionBuilder.cipher = try cfgContainer.decode(SessionProxy.Cipher.self, forKey: .cipher)
if let digest = try cfgContainer.decodeIfPresent(SessionProxy.Digest.self, forKey: .digest) {
var sessionBuilder = OpenVPN.ConfigurationBuilder()
sessionBuilder.cipher = try cfgContainer.decode(OpenVPN.Cipher.self, forKey: .cipher)
if let digest = try cfgContainer.decodeIfPresent(OpenVPN.Digest.self, forKey: .digest) {
sessionBuilder.digest = digest
}
sessionBuilder.compressionFraming = try cfgContainer.decode(SessionProxy.CompressionFraming.self, forKey: .compressionFraming)
sessionBuilder.compressionAlgorithm = try cfgContainer.decodeIfPresent(SessionProxy.CompressionAlgorithm.self, forKey: .compressionAlgorithm) ?? .disabled
sessionBuilder.ca = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .ca)
sessionBuilder.clientCertificate = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientCertificate)
sessionBuilder.clientKey = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientKey)
sessionBuilder.tlsWrap = try cfgContainer.decodeIfPresent(SessionProxy.TLSWrap.self, forKey: .tlsWrap)
sessionBuilder.compressionFraming = try cfgContainer.decode(OpenVPN.CompressionFraming.self, forKey: .compressionFraming)
sessionBuilder.compressionAlgorithm = try cfgContainer.decodeIfPresent(OpenVPN.CompressionAlgorithm.self, forKey: .compressionAlgorithm) ?? .disabled
sessionBuilder.ca = try cfgContainer.decodeIfPresent(OpenVPN.CryptoContainer.self, forKey: .ca)
sessionBuilder.clientCertificate = try cfgContainer.decodeIfPresent(OpenVPN.CryptoContainer.self, forKey: .clientCertificate)
sessionBuilder.clientKey = try cfgContainer.decodeIfPresent(OpenVPN.CryptoContainer.self, forKey: .clientKey)
sessionBuilder.tlsWrap = try cfgContainer.decodeIfPresent(OpenVPN.TLSWrap.self, forKey: .tlsWrap)
sessionBuilder.keepAliveInterval = try cfgContainer.decodeIfPresent(TimeInterval.self, forKey: .keepAliveSeconds)
sessionBuilder.renegotiatesAfter = try cfgContainer.decodeIfPresent(TimeInterval.self, forKey: .renegotiatesAfterSeconds)
sessionBuilder.endpointProtocols = try cfgContainer.decode([EndpointProtocol].self, forKey: .endpointProtocols)
@ -189,7 +189,7 @@ public struct InfrastructurePreset: Codable {
// default to server settings
sessionBuilder.routingPolicies = nil
let builder = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
let builder = OpenVPNTunnelProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
configuration = builder.build()
}

View File

@ -198,7 +198,7 @@ public class StandardVPNProvider: VPNProvider {
return
}
do {
try session.sendProviderMessage(TunnelKitProvider.Message.dataCount.data) { (data) in
try session.sendProviderMessage(OpenVPNTunnelProvider.Message.dataCount.data) { (data) in
guard let data = data, data.count == 16 else {
DispatchQueue.main.async {
completionHandler(nil)
@ -250,7 +250,7 @@ public class StandardVPNProvider: VPNProvider {
private static func requestDebugLog(session: NETunnelProviderSession, completionHandler: @escaping (String?) -> Void) {
do {
try session.sendProviderMessage(TunnelKitProvider.Message.requestLog.data) { (data) in
try session.sendProviderMessage(OpenVPNTunnelProvider.Message.requestLog.data) { (data) in
guard let data = data, !data.isEmpty else {
completionHandler(nil)
return

View File

@ -29,6 +29,6 @@ public class VPN {
#if targetEnvironment(simulator)
public static let shared = MockVPNProvider()
#else
public static let shared = StandardVPNProvider(bundleIdentifier: GroupConstants.App.tunnelIdentifier)
public static let shared = StandardVPNProvider(bundleIdentifier: AppConstants.App.tunnelBundleId)
#endif
}

View File

@ -5,13 +5,12 @@ use_frameworks!
load 'Podfile.include'
$tunnelkit_name = 'TunnelKit'
$tunnelkit_specs = ['Core', 'AppExtension', 'LZO']
#$tunnelkit_specs = ['OpenVPN', 'LZO']
$tunnelkit_specs = ['Protocols/OpenVPN', 'Extra/LZO']
def shared_pods
by_version('~> 1.7.1', $tunnelkit_name, $tunnelkit_specs)
#by_git('d06b2e1', $tunnelkit_name, $tunnelkit_specs)
#by_path('..', $tunnelkit_name, $tunnelkit_specs)
#pod_version $tunnelkit_name, $tunnelkit_specs, '~> 2.0.0'
pod_git $tunnelkit_name, $tunnelkit_specs, 'f3edd6e'
#pod_path $tunnelkit_name, $tunnelkit_specs, '..'
pod 'SSZipArchive'
end

View File

@ -1,18 +1,18 @@
$git_root = "https://github.com/passepartoutvpn"
def by_version(version, name, specs)
def pod_version(name, specs, version)
specs.each { |s|
pod "#{name}/#{s}", version
}
end
def by_git(sha, name, specs)
def pod_git(name, specs, sha)
specs.each { |s|
pod "#{name}/#{s}", :git => "#{$git_root}/#{name.downcase}", :commit => sha
}
end
def by_path(root, name, specs)
def pod_path(name, specs, root)
specs.each { |s|
pod "#{name}/#{s}", :path => "#{root}/#{name.downcase}"
}

View File

@ -1,22 +1,24 @@
PODS:
- MBProgressHUD (1.1.0)
- OpenSSL-Apple (1.1.0j.2)
- SSZipArchive (2.1.4)
- SSZipArchive (2.2.1)
- SwiftyBeaver (1.7.0)
- TunnelKit/AppExtension (1.7.1):
- TunnelKit/AppExtension (2.0.0):
- SwiftyBeaver
- TunnelKit/Core
- TunnelKit/Core (1.7.1):
- TunnelKit/Core (2.0.0):
- OpenSSL-Apple (~> 1.1.0j.2)
- SwiftyBeaver
- TunnelKit/LZO (1.7.1)
- TunnelKit/Extra/LZO (2.0.0)
- TunnelKit/Protocols/OpenVPN (2.0.0):
- TunnelKit/AppExtension
- TunnelKit/Core
DEPENDENCIES:
- MBProgressHUD
- SSZipArchive
- TunnelKit/AppExtension (~> 1.7.1)
- TunnelKit/Core (~> 1.7.1)
- TunnelKit/LZO (~> 1.7.1)
- TunnelKit/Extra/LZO (from `https://github.com/passepartoutvpn/tunnelkit`, commit `f3edd6e`)
- TunnelKit/Protocols/OpenVPN (from `https://github.com/passepartoutvpn/tunnelkit`, commit `f3edd6e`)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
@ -24,15 +26,24 @@ SPEC REPOS:
- OpenSSL-Apple
- SSZipArchive
- SwiftyBeaver
- TunnelKit
EXTERNAL SOURCES:
TunnelKit:
:commit: f3edd6e
:git: https://github.com/passepartoutvpn/tunnelkit
CHECKOUT OPTIONS:
TunnelKit:
:commit: f3edd6e
:git: https://github.com/passepartoutvpn/tunnelkit
SPEC CHECKSUMS:
MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9
OpenSSL-Apple: e88e1eb314acb4a05e2348069790c4aa49f6d319
SSZipArchive: 41455d4b8d2b6ab93990820b50dc697c2554a322
SSZipArchive: 8e859da2520142e09166bc9161967db296e9d02f
SwiftyBeaver: 4cc0080d2e23f980652e28978db11a5c9da39165
TunnelKit: d1e02dea5cb58ea0d4dbfcdcb387e653d148d800
TunnelKit: 821c15bb87aafae69eb8c63e4cc46d883fff8797
PODFILE CHECKSUM: fad46c04b9c9bee54cc740d6a4af257553ff635f
PODFILE CHECKSUM: b45e8f98f20b6c63f2735d1f038fb2e415601fbd
COCOAPODS: 1.6.1

View File

@ -108,12 +108,12 @@ For the VPN to work properly, the app requires:
both in the main app and the tunnel extension target.
Make sure to also update the following constants in `Passepartout/Sources/GroupConstants.swift` according to your developer account and your target bundle identifiers:
Make sure to update `Passepartout-iOS/Config.xcconfig` according to your developer account and your identifiers:
public static let teamId
public static let appId
public static let appGroup
public static let tunnelIdentifier
CFG_TEAM_ID = A1B2C3D4E5
CFG_APP_ID = com.example.ios.MyApp
CFG_GROUP_ID = com.example.MyAppGroup // omit the "group." prefix
CFG_APPSTORE_ID = 1234567890
## License