Upgrade to TunnelKit 2.0

Major reorganization. No changes in logic.

Rename by_* to pod_*.
This commit is contained in:
Davide De Rosa 2019-05-23 23:13:45 +02:00
parent 5b2ec85ee1
commit 87527ed290
24 changed files with 104 additions and 104 deletions

View File

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

View File

@ -106,11 +106,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
let passphraseCancelBlock = { let passphraseCancelBlock = {
_ = try? FileManager.default.removeItem(at: url) _ = 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 return true
} }
if let warning = parsingResult.warning { 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 { if $0 {
self.handleParsingResult(parsingResult, in: target) self.handleParsingResult(parsingResult, in: target)
} else { } else {
@ -123,7 +123,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
return true 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 // already presented: update parsed configuration
if let nav = target as? UINavigationController, let wizard = nav.topViewController as? WizardHostViewController { if let nav = target as? UINavigationController, let wizard = nav.topViewController as? WizardHostViewController {

View File

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

View File

@ -92,7 +92,7 @@ class IssueReporter: NSObject {
} }
if let url = configurationURL { if let url = configurationURL {
do { 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) { if let attachment = parsedFile.strippedLines?.joined(separator: "\n").data(using: .utf8) {
vc.addAttachmentData(attachment, mimeType: AppConstants.IssueReporter.MIME.configuration, fileName: AppConstants.IssueReporter.Filenames.configuration) vc.addAttachmentData(attachment, mimeType: AppConstants.IssueReporter.MIME.configuration, fileName: AppConstants.IssueReporter.Filenames.configuration)
} }

View File

@ -75,7 +75,7 @@ extension SettingTableViewCell {
accessoryType = .none 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 leftTextColor = theme.palette.primaryText
guard let vpnStatus = vpnStatus else { guard let vpnStatus = vpnStatus else {
rightText = L10n.Vpn.disabled rightText = L10n.Vpn.disabled

View File

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

View File

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

View File

@ -33,7 +33,7 @@ private let log = SwiftyBeaver.self
class ImportedHostsViewController: UITableViewController { class ImportedHostsViewController: UITableViewController {
private lazy var pendingConfigurationURLs = TransientStore.shared.service.pendingConfigurationURLs().sortedCaseInsensitive() private lazy var pendingConfigurationURLs = TransientStore.shared.service.pendingConfigurationURLs().sortedCaseInsensitive()
private var parsingResult: ConfigurationParser.Result? private var parsingResult: OpenVPN.ConfigurationParser.Result?
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
@ -88,7 +88,7 @@ class ImportedHostsViewController: UITableViewController {
} }
self.perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier, sender: cell) 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() deselectSelectedRow()
return false return false
} }
@ -96,7 +96,7 @@ class ImportedHostsViewController: UITableViewController {
// postpone segue until alert dismissal // postpone segue until alert dismissal
if let warning = parsingResult.warning { 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() self.deselectSelectedRow()
if $0 { if $0 {
self.perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier) self.perform(segue: StoryboardSegue.Organizer.importHostSegueIdentifier)

View File

@ -37,7 +37,7 @@ class WizardHostViewController: UITableViewController, TableModelHost {
return TransientStore.shared.service.ids(forContext: .host).sortedCaseInsensitive() return TransientStore.shared.service.ids(forContext: .host).sortedCaseInsensitive()
}() }()
var parsingResult: ConfigurationParser.Result? { var parsingResult: OpenVPN.ConfigurationParser.Result? {
didSet { didSet {
useSuggestedTitle() useSuggestedTitle()
} }
@ -104,7 +104,7 @@ class WizardHostViewController: UITableViewController, TableModelHost {
} }
let profile = HostConnectionProfile(title: enteredTitle, hostname: hostname) 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() profile.parameters = builder.build()
let service = TransientStore.shared.service let service = TransientStore.shared.service

View File

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

View File

@ -46,7 +46,7 @@ public protocol ConnectionProfile: class, EndpointDataSource, CustomStringConver
var manualNetworkSettings: ProfileNetworkSettings? { get set } 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 func with(newId: String) -> ConnectionProfile
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@ public class PlaceholderConnectionProfile: ConnectionProfile {
public var manualNetworkSettings: ProfileNetworkSettings? 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") fatalError("Generating configuration from a PlaceholderConnectionProfile")
} }

View File

@ -114,7 +114,7 @@ public class ProviderConnectionProfile: ConnectionProfile, Codable, Equatable {
return true 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 { guard let pool = pool else {
preconditionFailure("Nil pool?") preconditionFailure("Nil pool?")
} }

View File

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

View File

@ -75,9 +75,9 @@ public class TransientStore {
} }
} }
public static var baseVPNConfiguration: TunnelKitProvider.ConfigurationBuilder { public static var baseVPNConfiguration: OpenVPNTunnelProvider.ConfigurationBuilder {
let sessionBuilder = SessionProxy.ConfigurationBuilder() let sessionBuilder = OpenVPN.ConfigurationBuilder()
var builder = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build()) var builder = OpenVPNTunnelProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
builder.mtu = 1250 builder.mtu = 1250
builder.shouldDebug = true builder.shouldDebug = true
// builder.debugLogFormat = "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M" // builder.debugLogFormat = "$Dyyyy-MM-dd HH:mm:ss.SSS$d $L $N.$F:$l - $M"

View File

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

View File

@ -198,7 +198,7 @@ public class StandardVPNProvider: VPNProvider {
return return
} }
do { 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 { guard let data = data, data.count == 16 else {
DispatchQueue.main.async { DispatchQueue.main.async {
completionHandler(nil) completionHandler(nil)
@ -250,7 +250,7 @@ public class StandardVPNProvider: VPNProvider {
private static func requestDebugLog(session: NETunnelProviderSession, completionHandler: @escaping (String?) -> Void) { private static func requestDebugLog(session: NETunnelProviderSession, completionHandler: @escaping (String?) -> Void) {
do { 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 { guard let data = data, !data.isEmpty else {
completionHandler(nil) completionHandler(nil)
return return

View File

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

View File

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

View File

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