Upgrade TunnelKit with configuration refactoring
This commit is contained in:
parent
ae9c32e9f5
commit
542a3e3721
|
@ -27,7 +27,7 @@ import Foundation
|
||||||
import TunnelKit
|
import TunnelKit
|
||||||
|
|
||||||
protocol ConfigurationModificationDelegate: class {
|
protocol ConfigurationModificationDelegate: class {
|
||||||
func configuration(didUpdate newConfiguration: TunnelKitProvider.Configuration)
|
func configuration(didUpdate newConfiguration: SessionProxy.Configuration)
|
||||||
|
|
||||||
func configurationShouldReinstall()
|
func configurationShouldReinstall()
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,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: TunnelKitProvider.Configuration!
|
var initialConfiguration: SessionProxy.Configuration!
|
||||||
|
|
||||||
private lazy var configuration: TunnelKitProvider.ConfigurationBuilder = initialConfiguration.builder()
|
private lazy var configuration: SessionProxy.ConfigurationBuilder = initialConfiguration.builder()
|
||||||
|
|
||||||
var isEditable = false
|
var isEditable = false
|
||||||
|
|
||||||
|
@ -129,12 +129,12 @@ class ConfigurationViewController: UIViewController, TableModelHost {
|
||||||
log.warning("Could not parse original configuration: \(e)")
|
log.warning("Could not parse original configuration: \(e)")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
initialConfiguration = originalConfiguration
|
initialConfiguration = originalConfiguration.sessionConfiguration
|
||||||
configuration = originalConfiguration.builder()
|
configuration = initialConfiguration.builder()
|
||||||
itemRefresh.isEnabled = true // allow for manual reconnection
|
itemRefresh.isEnabled = true // allow for manual reconnection
|
||||||
tableView.reloadData()
|
tableView.reloadData()
|
||||||
|
|
||||||
delegate?.configuration(didUpdate: originalConfiguration)
|
delegate?.configuration(didUpdate: initialConfiguration)
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction private func refresh() {
|
@IBAction private func refresh() {
|
||||||
|
@ -270,8 +270,8 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
|
||||||
case .keepAlive:
|
case .keepAlive:
|
||||||
cell.leftText = L10n.Configuration.Cells.KeepAlive.caption
|
cell.leftText = L10n.Configuration.Cells.KeepAlive.caption
|
||||||
let V = L10n.Configuration.Cells.KeepAlive.Value.self
|
let V = L10n.Configuration.Cells.KeepAlive.Value.self
|
||||||
if let keepAlive = configuration.keepAliveSeconds, keepAlive > 0 {
|
if let keepAlive = configuration.keepAliveInterval, keepAlive > 0 {
|
||||||
cell.rightText = V.seconds(keepAlive)
|
cell.rightText = V.seconds(Int(keepAlive))
|
||||||
} else {
|
} else {
|
||||||
cell.rightText = V.never
|
cell.rightText = V.never
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
|
||||||
case .renegSeconds:
|
case .renegSeconds:
|
||||||
cell.leftText = L10n.Configuration.Cells.RenegotiationSeconds.caption
|
cell.leftText = L10n.Configuration.Cells.RenegotiationSeconds.caption
|
||||||
let V = L10n.Configuration.Cells.RenegotiationSeconds.Value.self
|
let V = L10n.Configuration.Cells.RenegotiationSeconds.Value.self
|
||||||
if let reneg = configuration.renegotiatesAfterSeconds, reneg > 0 {
|
if let reneg = configuration.renegotiatesAfter, reneg > 0 {
|
||||||
cell.rightText = V.after(TimeInterval(reneg).localized)
|
cell.rightText = V.after(TimeInterval(reneg).localized)
|
||||||
} else {
|
} else {
|
||||||
cell.rightText = V.never
|
cell.rightText = V.never
|
||||||
|
|
|
@ -129,7 +129,7 @@ extension ProviderPresetViewController: UITableViewDataSource, UITableViewDelega
|
||||||
case .techDetails:
|
case .techDetails:
|
||||||
let vc = StoryboardScene.Main.configurationIdentifier.instantiate()
|
let vc = StoryboardScene.Main.configurationIdentifier.instantiate()
|
||||||
vc.title = preset.name
|
vc.title = preset.name
|
||||||
vc.initialConfiguration = preset.configuration
|
vc.initialConfiguration = preset.configuration.sessionConfiguration
|
||||||
navigationController?.pushViewController(vc, animated: true)
|
navigationController?.pushViewController(vc, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ class ServiceViewController: UIViewController, TableModelHost {
|
||||||
case .hostParametersSegueIdentifier:
|
case .hostParametersSegueIdentifier:
|
||||||
let vc = destination as? ConfigurationViewController
|
let vc = destination as? ConfigurationViewController
|
||||||
vc?.title = L10n.Service.Cells.Host.Parameters.caption
|
vc?.title = L10n.Service.Cells.Host.Parameters.caption
|
||||||
vc?.initialConfiguration = uncheckedHostProfile.parameters
|
vc?.initialConfiguration = uncheckedHostProfile.parameters.sessionConfiguration
|
||||||
vc?.isEditable = true
|
vc?.isEditable = true
|
||||||
vc?.originalConfigurationURL = ProfileConfigurationFactory.shared.configurationURL(for: uncheckedHostProfile)
|
vc?.originalConfigurationURL = ProfileConfigurationFactory.shared.configurationURL(for: uncheckedHostProfile)
|
||||||
vc?.delegate = self
|
vc?.delegate = self
|
||||||
|
@ -595,10 +595,10 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
|
||||||
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
|
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
|
||||||
cell.leftText = L10n.Service.Cells.Host.Parameters.caption
|
cell.leftText = L10n.Service.Cells.Host.Parameters.caption
|
||||||
let V = L10n.Service.Cells.Host.Parameters.Value.self
|
let V = L10n.Service.Cells.Host.Parameters.Value.self
|
||||||
if !parameters.cipher.embedsDigest {
|
if !parameters.sessionConfiguration.cipher.embedsDigest {
|
||||||
cell.rightText = V.cipherDigest(parameters.cipher.genericName, parameters.digest.genericName)
|
cell.rightText = V.cipherDigest(parameters.sessionConfiguration.cipher.genericName, parameters.sessionConfiguration.digest.genericName)
|
||||||
} else {
|
} else {
|
||||||
cell.rightText = V.cipher(parameters.cipher.genericName)
|
cell.rightText = V.cipher(parameters.sessionConfiguration.cipher.genericName)
|
||||||
}
|
}
|
||||||
return cell
|
return cell
|
||||||
|
|
||||||
|
@ -973,9 +973,11 @@ extension ServiceViewController: TrustedNetworksModelDelegate {
|
||||||
// MARK: -
|
// MARK: -
|
||||||
|
|
||||||
extension ServiceViewController: ConfigurationModificationDelegate {
|
extension ServiceViewController: ConfigurationModificationDelegate {
|
||||||
func configuration(didUpdate newConfiguration: TunnelKitProvider.Configuration) {
|
func configuration(didUpdate newConfiguration: SessionProxy.Configuration) {
|
||||||
if let hostProfile = profile as? HostConnectionProfile {
|
if let hostProfile = profile as? HostConnectionProfile {
|
||||||
hostProfile.parameters = newConfiguration
|
var builder = hostProfile.parameters.builder()
|
||||||
|
builder.sessionConfiguration = newConfiguration
|
||||||
|
hostProfile.parameters = builder.build()
|
||||||
}
|
}
|
||||||
reloadSelectedRow()
|
reloadSelectedRow()
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
0E6BE13A20CFB76800A6DD36 /* ApplicationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */; };
|
0E6BE13A20CFB76800A6DD36 /* ApplicationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */; };
|
||||||
0E6BE13F20CFBAB300A6DD36 /* DebugLogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */; };
|
0E6BE13F20CFBAB300A6DD36 /* DebugLogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */; };
|
||||||
0E89DFC5213DF7AE00741BA1 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFC4213DF7AE00741BA1 /* Preferences.swift */; };
|
0E89DFC5213DF7AE00741BA1 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFC4213DF7AE00741BA1 /* Preferences.swift */; };
|
||||||
0E89DFC8213E8FC500741BA1 /* TunnelKitProvider+Communication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFC7213E8FC500741BA1 /* TunnelKitProvider+Communication.swift */; };
|
0E89DFC8213E8FC500741BA1 /* SessionProxy+Communication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFC7213E8FC500741BA1 /* SessionProxy+Communication.swift */; };
|
||||||
0E89DFCE213EEDFA00741BA1 /* WizardProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */; };
|
0E89DFCE213EEDFA00741BA1 /* WizardProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */; };
|
||||||
0E89DFD0213F223400741BA1 /* Wizard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFCF213F223400741BA1 /* Wizard.swift */; };
|
0E89DFD0213F223400741BA1 /* Wizard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFCF213F223400741BA1 /* Wizard.swift */; };
|
||||||
0E8D97E221388B52006FB4A0 /* InfrastructurePreset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E8D97E121388B52006FB4A0 /* InfrastructurePreset.swift */; };
|
0E8D97E221388B52006FB4A0 /* InfrastructurePreset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E8D97E121388B52006FB4A0 /* InfrastructurePreset.swift */; };
|
||||||
|
@ -159,7 +159,7 @@
|
||||||
0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationError.swift; sourceTree = "<group>"; };
|
0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationError.swift; sourceTree = "<group>"; };
|
||||||
0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebugLogViewController.swift; sourceTree = "<group>"; };
|
0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebugLogViewController.swift; sourceTree = "<group>"; };
|
||||||
0E89DFC4213DF7AE00741BA1 /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
|
0E89DFC4213DF7AE00741BA1 /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
|
||||||
0E89DFC7213E8FC500741BA1 /* TunnelKitProvider+Communication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TunnelKitProvider+Communication.swift"; sourceTree = "<group>"; };
|
0E89DFC7213E8FC500741BA1 /* SessionProxy+Communication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SessionProxy+Communication.swift"; sourceTree = "<group>"; };
|
||||||
0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WizardProviderViewController.swift; sourceTree = "<group>"; };
|
0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WizardProviderViewController.swift; sourceTree = "<group>"; };
|
||||||
0E89DFCF213F223400741BA1 /* Wizard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wizard.swift; sourceTree = "<group>"; };
|
0E89DFCF213F223400741BA1 /* Wizard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Wizard.swift; sourceTree = "<group>"; };
|
||||||
0E8D97E121388B52006FB4A0 /* InfrastructurePreset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfrastructurePreset.swift; sourceTree = "<group>"; };
|
0E8D97E121388B52006FB4A0 /* InfrastructurePreset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfrastructurePreset.swift; sourceTree = "<group>"; };
|
||||||
|
@ -382,7 +382,7 @@
|
||||||
0ED38AE621404F100004D387 /* EndpointDataSource.swift */,
|
0ED38AE621404F100004D387 /* EndpointDataSource.swift */,
|
||||||
0E89DFC4213DF7AE00741BA1 /* Preferences.swift */,
|
0E89DFC4213DF7AE00741BA1 /* Preferences.swift */,
|
||||||
0E2D11B9217DBEDE0096822C /* ProfileConfigurationFactory.swift */,
|
0E2D11B9217DBEDE0096822C /* ProfileConfigurationFactory.swift */,
|
||||||
0E89DFC7213E8FC500741BA1 /* TunnelKitProvider+Communication.swift */,
|
0E89DFC7213E8FC500741BA1 /* SessionProxy+Communication.swift */,
|
||||||
0E2B494120FD16540094784C /* TransientStore.swift */,
|
0E2B494120FD16540094784C /* TransientStore.swift */,
|
||||||
0E4C9CB820DB9BC600A0C59C /* TrustedNetworks.swift */,
|
0E4C9CB820DB9BC600A0C59C /* TrustedNetworks.swift */,
|
||||||
0EBE3A8F213C6F4000BFA2F5 /* TrustPolicy.swift */,
|
0EBE3A8F213C6F4000BFA2F5 /* TrustPolicy.swift */,
|
||||||
|
@ -837,7 +837,7 @@
|
||||||
0E2D11BA217DBEDE0096822C /* ProfileConfigurationFactory.swift in Sources */,
|
0E2D11BA217DBEDE0096822C /* ProfileConfigurationFactory.swift in Sources */,
|
||||||
0EBE3A90213C6F4000BFA2F5 /* TrustPolicy.swift in Sources */,
|
0EBE3A90213C6F4000BFA2F5 /* TrustPolicy.swift in Sources */,
|
||||||
0E6BE13F20CFBAB300A6DD36 /* DebugLogViewController.swift in Sources */,
|
0E6BE13F20CFBAB300A6DD36 /* DebugLogViewController.swift in Sources */,
|
||||||
0E89DFC8213E8FC500741BA1 /* TunnelKitProvider+Communication.swift in Sources */,
|
0E89DFC8213E8FC500741BA1 /* SessionProxy+Communication.swift in Sources */,
|
||||||
0ED38AEA214054A50004D387 /* OptionViewController.swift in Sources */,
|
0ED38AEA214054A50004D387 /* OptionViewController.swift in Sources */,
|
||||||
0EFD943E215BE10800529B64 /* IssueReporter.swift in Sources */,
|
0EFD943E215BE10800529B64 /* IssueReporter.swift in Sources */,
|
||||||
0EBE3AAC213DEB8800BFA2F5 /* ConnectionProfileHolder.swift in Sources */,
|
0EBE3AAC213DEB8800BFA2F5 /* ConnectionProfileHolder.swift in Sources */,
|
||||||
|
|
|
@ -42,7 +42,8 @@ class AppConstants {
|
||||||
|
|
||||||
class VPN {
|
class VPN {
|
||||||
static func tunnelConfiguration() -> TunnelKitProvider.Configuration {
|
static func tunnelConfiguration() -> TunnelKitProvider.Configuration {
|
||||||
var builder = TunnelKitProvider.ConfigurationBuilder(ca: CryptoContainer(pem: ""))
|
let sessionBuilder = SessionProxy.ConfigurationBuilder(ca: CryptoContainer(pem: ""))
|
||||||
|
var builder = TunnelKitProvider.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"
|
||||||
|
|
|
@ -34,7 +34,8 @@ class HostConnectionProfile: ConnectionProfile, Codable, Equatable {
|
||||||
init(title: String, hostname: String) {
|
init(title: String, hostname: String) {
|
||||||
self.title = title
|
self.title = title
|
||||||
self.hostname = hostname
|
self.hostname = hostname
|
||||||
parameters = TunnelKitProvider.ConfigurationBuilder(ca: CryptoContainer(pem: "")).build()
|
let sessionConfiguration = SessionProxy.ConfigurationBuilder(ca: CryptoContainer(pem: "")).build()
|
||||||
|
parameters = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: sessionConfiguration).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: ConnectionProfile
|
// MARK: ConnectionProfile
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//
|
//
|
||||||
// TunnelKitProvider+Communication.swift
|
// SessionProxy+Communication.swift
|
||||||
// Passepartout
|
// Passepartout
|
||||||
//
|
//
|
||||||
// Created by Davide De Rosa on 9/4/18.
|
// Created by Davide De Rosa on 9/4/18.
|
||||||
|
@ -26,15 +26,16 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import TunnelKit
|
import TunnelKit
|
||||||
|
|
||||||
extension TunnelKitProvider.ConfigurationBuilder {
|
extension SessionProxy.ConfigurationBuilder {
|
||||||
// mutating func copyCommunication(from other: TunnelKitProvider.ConfigurationBuilder) {
|
// mutating func copyCommunication(from other: SessionProxy.ConfigurationBuilder) {
|
||||||
// cipher = other.cipher
|
// cipher = other.cipher
|
||||||
// digest = other.digest
|
// digest = other.digest
|
||||||
// compressionFraming = other.compressionFraming
|
// compressionFraming = other.compressionFraming
|
||||||
// }
|
// }
|
||||||
|
|
||||||
func canCommunicate(with other: TunnelKitProvider.Configuration) -> Bool {
|
func canCommunicate(with other: SessionProxy.Configuration) -> Bool {
|
||||||
return (cipher == other.cipher) &&
|
return
|
||||||
|
(cipher == other.cipher) &&
|
||||||
((digest == other.digest) || cipher.embedsDigest) &&
|
((digest == other.digest) || cipher.embedsDigest) &&
|
||||||
(compressionFraming == other.compressionFraming)
|
(compressionFraming == other.compressionFraming)
|
||||||
}
|
}
|
|
@ -84,18 +84,21 @@ struct InfrastructurePreset: Codable {
|
||||||
|
|
||||||
let cfgContainer = try container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration)
|
let cfgContainer = try container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration)
|
||||||
let ca = try cfgContainer.decode(CryptoContainer.self, forKey: .ca)
|
let ca = try cfgContainer.decode(CryptoContainer.self, forKey: .ca)
|
||||||
var builder = TunnelKitProvider.ConfigurationBuilder(ca: ca)
|
|
||||||
builder.endpointProtocols = try cfgContainer.decode([TunnelKitProvider.EndpointProtocol].self, forKey: .endpointProtocols)
|
var sessionBuilder = SessionProxy.ConfigurationBuilder(ca: ca)
|
||||||
builder.cipher = try cfgContainer.decode(SessionProxy.Cipher.self, forKey: .cipher)
|
sessionBuilder.cipher = try cfgContainer.decode(SessionProxy.Cipher.self, forKey: .cipher)
|
||||||
if let digest = try cfgContainer.decodeIfPresent(SessionProxy.Digest.self, forKey: .digest) {
|
if let digest = try cfgContainer.decodeIfPresent(SessionProxy.Digest.self, forKey: .digest) {
|
||||||
builder.digest = digest
|
sessionBuilder.digest = digest
|
||||||
}
|
}
|
||||||
builder.clientCertificate = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientCertificate)
|
sessionBuilder.clientCertificate = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientCertificate)
|
||||||
builder.clientKey = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientKey)
|
sessionBuilder.clientKey = try cfgContainer.decodeIfPresent(CryptoContainer.self, forKey: .clientKey)
|
||||||
builder.compressionFraming = try cfgContainer.decode(SessionProxy.CompressionFraming.self, forKey: .compressionFraming)
|
sessionBuilder.compressionFraming = try cfgContainer.decode(SessionProxy.CompressionFraming.self, forKey: .compressionFraming)
|
||||||
builder.keepAliveSeconds = try cfgContainer.decodeIfPresent(Int.self, forKey: .keepAliveSeconds)
|
sessionBuilder.keepAliveInterval = try cfgContainer.decodeIfPresent(TimeInterval.self, forKey: .keepAliveSeconds)
|
||||||
builder.renegotiatesAfterSeconds = try cfgContainer.decodeIfPresent(Int.self, forKey: .renegotiatesAfterSeconds)
|
sessionBuilder.renegotiatesAfter = try cfgContainer.decodeIfPresent(TimeInterval.self, forKey: .renegotiatesAfterSeconds)
|
||||||
builder.usesPIAPatches = try cfgContainer.decodeIfPresent(Bool.self, forKey: .usesPIAPatches) ?? false
|
sessionBuilder.usesPIAPatches = try cfgContainer.decodeIfPresent(Bool.self, forKey: .usesPIAPatches) ?? false
|
||||||
|
|
||||||
|
var builder = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
|
||||||
|
builder.endpointProtocols = try cfgContainer.decode([TunnelKitProvider.EndpointProtocol].self, forKey: .endpointProtocols)
|
||||||
configuration = builder.build()
|
configuration = builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,14 +110,15 @@ struct InfrastructurePreset: Codable {
|
||||||
|
|
||||||
var cfgContainer = container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration)
|
var cfgContainer = container.nestedContainer(keyedBy: ConfigurationKeys.self, forKey: .configuration)
|
||||||
try cfgContainer.encode(configuration.endpointProtocols, forKey: .endpointProtocols)
|
try cfgContainer.encode(configuration.endpointProtocols, forKey: .endpointProtocols)
|
||||||
try cfgContainer.encode(configuration.cipher, forKey: .cipher)
|
|
||||||
try cfgContainer.encode(configuration.digest, forKey: .digest)
|
try cfgContainer.encode(configuration.sessionConfiguration.cipher, forKey: .cipher)
|
||||||
try cfgContainer.encodeIfPresent(configuration.ca, forKey: .ca)
|
try cfgContainer.encode(configuration.sessionConfiguration.digest, forKey: .digest)
|
||||||
try cfgContainer.encodeIfPresent(configuration.clientCertificate, forKey: .clientCertificate)
|
try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.ca, forKey: .ca)
|
||||||
try cfgContainer.encodeIfPresent(configuration.clientKey, forKey: .clientKey)
|
try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.clientCertificate, forKey: .clientCertificate)
|
||||||
try cfgContainer.encode(configuration.compressionFraming, forKey: .compressionFraming)
|
try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.clientKey, forKey: .clientKey)
|
||||||
try cfgContainer.encodeIfPresent(configuration.keepAliveSeconds, forKey: .keepAliveSeconds)
|
try cfgContainer.encode(configuration.sessionConfiguration.compressionFraming, forKey: .compressionFraming)
|
||||||
try cfgContainer.encodeIfPresent(configuration.renegotiatesAfterSeconds, forKey: .renegotiatesAfterSeconds)
|
try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.keepAliveInterval, forKey: .keepAliveSeconds)
|
||||||
try cfgContainer.encodeIfPresent(configuration.usesPIAPatches, forKey: .usesPIAPatches)
|
try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.renegotiatesAfter, forKey: .renegotiatesAfterSeconds)
|
||||||
|
try cfgContainer.encodeIfPresent(configuration.sessionConfiguration.usesPIAPatches, forKey: .usesPIAPatches)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,8 +75,8 @@ extension TunnelKitProvider.Configuration {
|
||||||
var optCA: CryptoContainer?
|
var optCA: CryptoContainer?
|
||||||
var clientCertificate: CryptoContainer?
|
var clientCertificate: CryptoContainer?
|
||||||
var clientKey: CryptoContainer?
|
var clientKey: CryptoContainer?
|
||||||
var keepAliveSeconds: Int?
|
var keepAliveSeconds: TimeInterval?
|
||||||
var renegotiateAfterSeconds: Int?
|
var renegotiateAfterSeconds: TimeInterval?
|
||||||
var keyDirection: StaticKey.Direction?
|
var keyDirection: StaticKey.Direction?
|
||||||
var tlsStrategy: SessionProxy.TLSWrap.Strategy?
|
var tlsStrategy: SessionProxy.TLSWrap.Strategy?
|
||||||
var tlsKeyLines: [Substring]?
|
var tlsKeyLines: [Substring]?
|
||||||
|
@ -202,13 +202,13 @@ extension TunnelKitProvider.Configuration {
|
||||||
guard let arg = $0.first else {
|
guard let arg = $0.first else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
keepAliveSeconds = Int(arg)
|
keepAliveSeconds = TimeInterval(arg)
|
||||||
}
|
}
|
||||||
Regex.renegSec.enumerateArguments(in: line) {
|
Regex.renegSec.enumerateArguments(in: line) {
|
||||||
guard let arg = $0.first else {
|
guard let arg = $0.first else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
renegotiateAfterSeconds = Int(arg)
|
renegotiateAfterSeconds = TimeInterval(arg)
|
||||||
}
|
}
|
||||||
Regex.fragment.enumerateArguments(in: line) { (_) in
|
Regex.fragment.enumerateArguments(in: line) { (_) in
|
||||||
unsupportedError = ApplicationError.unsupportedConfiguration(option: "fragment")
|
unsupportedError = ApplicationError.unsupportedConfiguration(option: "fragment")
|
||||||
|
@ -270,16 +270,17 @@ extension TunnelKitProvider.Configuration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var builder = TunnelKitProvider.ConfigurationBuilder(ca: ca)
|
var sessionBuilder = SessionProxy.ConfigurationBuilder(ca: ca)
|
||||||
|
sessionBuilder.cipher = cipher ?? .aes128cbc
|
||||||
|
sessionBuilder.digest = digest ?? .sha1
|
||||||
|
sessionBuilder.compressionFraming = compressionFraming
|
||||||
|
sessionBuilder.tlsWrap = tlsWrap
|
||||||
|
sessionBuilder.clientCertificate = clientCertificate
|
||||||
|
sessionBuilder.clientKey = clientKey
|
||||||
|
sessionBuilder.keepAliveInterval = keepAliveSeconds
|
||||||
|
sessionBuilder.renegotiatesAfter = renegotiateAfterSeconds
|
||||||
|
var builder = TunnelKitProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
|
||||||
builder.endpointProtocols = endpointProtocols
|
builder.endpointProtocols = endpointProtocols
|
||||||
builder.cipher = cipher ?? .aes128cbc
|
|
||||||
builder.digest = digest ?? .sha1
|
|
||||||
builder.compressionFraming = compressionFraming
|
|
||||||
builder.tlsWrap = tlsWrap
|
|
||||||
builder.clientCertificate = clientCertificate
|
|
||||||
builder.clientKey = clientKey
|
|
||||||
builder.keepAliveSeconds = keepAliveSeconds
|
|
||||||
builder.renegotiatesAfterSeconds = renegotiateAfterSeconds
|
|
||||||
|
|
||||||
return (hostname, builder.build())
|
return (hostname, builder.build())
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ class FileConfigurationTests: XCTestCase {
|
||||||
|
|
||||||
func testPIA() throws {
|
func testPIA() throws {
|
||||||
let cfg = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary")).1
|
let cfg = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary")).1
|
||||||
XCTAssertEqual(cfg.cipher, .aes128cbc)
|
XCTAssertEqual(cfg.sessionConfiguration.cipher, .aes128cbc)
|
||||||
XCTAssertEqual(cfg.digest, .sha1)
|
XCTAssertEqual(cfg.sessionConfiguration.digest, .sha1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func url(withName name: String) -> URL {
|
private func url(withName name: String) -> URL {
|
||||||
|
|
2
Podfile
2
Podfile
|
@ -3,7 +3,7 @@ use_frameworks!
|
||||||
|
|
||||||
def shared_pods
|
def shared_pods
|
||||||
#pod 'TunnelKit', '~> 1.1.2'
|
#pod 'TunnelKit', '~> 1.1.2'
|
||||||
pod 'TunnelKit', :git => 'https://github.com/keeshux/tunnelkit', :commit => '6995b88'
|
pod 'TunnelKit', :git => 'https://github.com/keeshux/tunnelkit', :commit => 'd94733f'
|
||||||
#pod 'TunnelKit', :path => '../tunnelkit'
|
#pod 'TunnelKit', :path => '../tunnelkit'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
20
Podfile.lock
20
Podfile.lock
|
@ -2,19 +2,19 @@ PODS:
|
||||||
- MBProgressHUD (1.1.0)
|
- MBProgressHUD (1.1.0)
|
||||||
- OpenSSL-Apple (1.1.0i-v2)
|
- OpenSSL-Apple (1.1.0i-v2)
|
||||||
- SwiftyBeaver (1.6.1)
|
- SwiftyBeaver (1.6.1)
|
||||||
- TunnelKit (1.2.2):
|
- TunnelKit (1.3.0):
|
||||||
- TunnelKit/AppExtension (= 1.2.2)
|
- TunnelKit/AppExtension (= 1.3.0)
|
||||||
- TunnelKit/Core (= 1.2.2)
|
- TunnelKit/Core (= 1.3.0)
|
||||||
- TunnelKit/AppExtension (1.2.2):
|
- TunnelKit/AppExtension (1.3.0):
|
||||||
- SwiftyBeaver
|
- SwiftyBeaver
|
||||||
- TunnelKit/Core
|
- TunnelKit/Core
|
||||||
- TunnelKit/Core (1.2.2):
|
- TunnelKit/Core (1.3.0):
|
||||||
- OpenSSL-Apple (~> 1.1.0h)
|
- OpenSSL-Apple (~> 1.1.0h)
|
||||||
- SwiftyBeaver
|
- SwiftyBeaver
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- MBProgressHUD
|
- MBProgressHUD
|
||||||
- TunnelKit (from `https://github.com/keeshux/tunnelkit`, commit `6995b88`)
|
- TunnelKit (from `https://github.com/keeshux/tunnelkit`, commit `d94733f`)
|
||||||
|
|
||||||
SPEC REPOS:
|
SPEC REPOS:
|
||||||
https://github.com/cocoapods/specs.git:
|
https://github.com/cocoapods/specs.git:
|
||||||
|
@ -24,20 +24,20 @@ SPEC REPOS:
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
TunnelKit:
|
TunnelKit:
|
||||||
:commit: 6995b88
|
:commit: d94733f
|
||||||
:git: https://github.com/keeshux/tunnelkit
|
:git: https://github.com/keeshux/tunnelkit
|
||||||
|
|
||||||
CHECKOUT OPTIONS:
|
CHECKOUT OPTIONS:
|
||||||
TunnelKit:
|
TunnelKit:
|
||||||
:commit: 6995b88
|
:commit: d94733f
|
||||||
:git: https://github.com/keeshux/tunnelkit
|
:git: https://github.com/keeshux/tunnelkit
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9
|
MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9
|
||||||
OpenSSL-Apple: a93b8f2eec8783ff40d9a9304de180ab68bb647c
|
OpenSSL-Apple: a93b8f2eec8783ff40d9a9304de180ab68bb647c
|
||||||
SwiftyBeaver: ccfcdf85a04d429f1633f668650b0ce8020bda3a
|
SwiftyBeaver: ccfcdf85a04d429f1633f668650b0ce8020bda3a
|
||||||
TunnelKit: 15c88f0cef7b926883566a9455e912a1e55f4048
|
TunnelKit: 8e747cac28959ebfdfa4eeab589c933f1856c0fb
|
||||||
|
|
||||||
PODFILE CHECKSUM: 159cfb999715d0ff9a22a7824f3b25dea9908ef0
|
PODFILE CHECKSUM: 38237684ab2fdb5e262da936fd6932218abca0b4
|
||||||
|
|
||||||
COCOAPODS: 1.6.0.beta.2
|
COCOAPODS: 1.6.0.beta.2
|
||||||
|
|
Loading…
Reference in New Issue