Commit 94643b2d authored by Davide De Rosa's avatar Davide De Rosa
Browse files

Convert socketType/port to EndpointProtocol

Upgrade to PIALibrary 1.1.2

No migration, user will have to re-set socket/port manually. Will
default to all UDP ports.
parent f707363f
......@@ -96,27 +96,37 @@ class Bootstrapper {
Client.useMockAccountProvider(AppConfiguration.Mock.accountProvider)
}
// as per App Store guidelines
Client.bootstrap()
// Preferences
let pref = Client.preferences.editable()
let tunnelConfiguration = pref.vpnCustomConfiguration(for: PIATunnelProfile.vpnType) as? PIATunnelProvider.Configuration
var tunnelConfigurationBuilder = tunnelConfiguration?.builder()
// as per App Store guidelines
if !Flags.shared.enablesMACESetting {
pref.mace = false
}
if !Flags.shared.enablesRemotePortSetting {
pref.preferredPort = nil
}
if !Flags.shared.enablesSocketSetting {
pref.preferredPort = nil
tunnelConfigurationBuilder?.socketType = .udp
}
if let newConfiguration = tunnelConfigurationBuilder?.build() {
pref.setVPNCustomConfiguration(newConfiguration, for: PIATunnelProfile.vpnType)
// automatic
let tunnelConfiguration = pref.vpnCustomConfiguration(for: PIATunnelProfile.vpnType) as? PIATunnelProvider.Configuration
if tunnelConfiguration?.endpointProtocols.isEmpty ?? true {
var tunnelConfigurationBuilder = tunnelConfiguration?.builder()
let vpnPorts = Client.providers.serverProvider.currentServersConfiguration.vpnPorts
var protos: [PIATunnelProvider.EndpointProtocol] = []
for port in vpnPorts.udp {
protos.append(PIATunnelProvider.EndpointProtocol(.udp, port, .pia))
}
// for port in vpnPorts.tcp {
// protos.append(PIATunnelProvider.EndpointProtocol(.tcp, port, .pia))
// }
tunnelConfigurationBuilder?.endpointProtocols = protos
if let newConfiguration = tunnelConfigurationBuilder?.build() {
pref.setVPNCustomConfiguration(newConfiguration, for: PIATunnelProfile.vpnType)
}
}
pref.commit()
Client.bootstrap()
// Business objects
AccountObserver.shared.start()
......
......@@ -26,10 +26,6 @@
<true/>
<key>enablesEncryptionSettings</key>
<true/>
<key>enablesRemotePortSetting</key>
<true/>
<key>enablesSocketSetting</key>
<true/>
<key>enablesDevelopmentSettings</key>
<true/>
<key>customizesVPNRenegotiation</key>
......
......@@ -38,10 +38,6 @@ class Flags: NSObject {
@objc private(set) var enablesEncryptionSettings = true
@objc private(set) var enablesRemotePortSetting = true
@objc private(set) var enablesSocketSetting = true
@objc private(set) var enablesDevelopmentSettings = false
@objc private(set) var customizesVPNRenegotiation = false
......
......@@ -632,21 +632,25 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
}
case .vpnSocket:
cell.textLabel?.text = L10n.Settings.Connection.SocketProtocol.title
cell.detailTextLabel?.text = pendingOpenVPNConfiguration.socketType.description
if !Flags.shared.enablesSocketSetting {
cell.accessoryType = .none
cell.selectionStyle = .none
}
// FIXME
break
// cell.textLabel?.text = L10n.Settings.Connection.SocketProtocol.title
// cell.detailTextLabel?.text = pendingOpenVPNConfiguration.socketType.description
// if !Flags.shared.enablesSocketSetting {
// cell.accessoryType = .none
// cell.selectionStyle = .none
// }
case .vpnPort:
cell.textLabel?.text = L10n.Settings.Connection.RemotePort.title
cell.detailTextLabel?.text = pendingPreferences.preferredPort?.description ?? L10n.Global.automatic
if !Flags.shared.enablesRemotePortSetting {
cell.detailTextLabel?.text = Client.providers.serverProvider.targetServer.bestOpenVPNAddressForUDP?.port.description
cell.accessoryType = .none
cell.selectionStyle = .none
}
// FIXME
break
// cell.textLabel?.text = L10n.Settings.Connection.RemotePort.title
// cell.detailTextLabel?.text = pendingPreferences.preferredPort?.description ?? L10n.Global.automatic
// if !Flags.shared.enablesRemotePortSetting {
// cell.detailTextLabel?.text = Client.providers.serverProvider.targetServer.bestOpenVPNAddressForUDP?.port.description
// cell.accessoryType = .none
// cell.selectionStyle = .none
// }
case .encryptionCipher:
cell.textLabel?.text = L10n.Settings.Encryption.Cipher.title
......@@ -756,27 +760,31 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
controller?.selectedOption = pendingPreferences.vpnType
case .vpnSocket:
guard Flags.shared.enablesSocketSetting else {
break
}
let options: [PIATunnelProvider.SocketType] = [
.udp,
.tcp
]
controller = OptionsViewController()
controller?.options = options.map { $0.rawValue }
controller?.selectedOption = pendingOpenVPNConfiguration.socketType.rawValue
// FIXME
break
// guard Flags.shared.enablesSocketSetting else {
// break
// }
// let options: [PIATunnelProvider.SocketType] = [
// .udp,
// .tcp
// ]
// controller = OptionsViewController()
// controller?.options = options.map { $0.rawValue }
// controller?.selectedOption = pendingOpenVPNConfiguration.socketType.rawValue
case .vpnPort:
guard Flags.shared.enablesRemotePortSetting else {
break
}
let availablePorts = Client.providers.serverProvider.currentServersConfiguration.vpnPorts
var options = (pendingOpenVPNConfiguration.socketType == .udp) ? availablePorts.udp : availablePorts.tcp
options.insert(SettingsViewController.AUTOMATIC_PORT, at: 0)
controller = OptionsViewController()
controller?.options = options
controller?.selectedOption = pendingPreferences.preferredPort ?? SettingsViewController.AUTOMATIC_PORT
// FIXME
break
// guard Flags.shared.enablesRemotePortSetting else {
// break
// }
// let availablePorts = Client.providers.serverProvider.currentServersConfiguration.vpnPorts
// var options = (pendingOpenVPNConfiguration.socketType == .udp) ? availablePorts.udp : availablePorts.tcp
// options.insert(SettingsViewController.AUTOMATIC_PORT, at: 0)
// controller = OptionsViewController()
// controller?.options = options
// controller?.selectedOption = pendingPreferences.preferredPort ?? SettingsViewController.AUTOMATIC_PORT
case .encryptionCipher:
guard Flags.shared.enablesEncryptionSettings else {
......@@ -946,13 +954,17 @@ extension SettingsViewController: OptionsViewControllerDelegate {
pendingPreferences.vpnType = vpnType
case .vpnSocket:
let rawSocketType = option as! String
pendingOpenVPNConfiguration.socketType = PIATunnelProvider.SocketType(rawValue: rawSocketType)!
pendingPreferences.preferredPort = nil
// FIXME
break
// let rawSocketType = option as! String
// pendingOpenVPNConfiguration.socketType = PIATunnelProvider.SocketType(rawValue: rawSocketType)!
// pendingPreferences.preferredPort = nil
case .vpnPort:
let port = option as! UInt16
pendingPreferences.preferredPort = (port != SettingsViewController.AUTOMATIC_PORT) ? port : nil
// FIXME
break
// let port = option as! UInt16
// pendingPreferences.preferredPort = (port != SettingsViewController.AUTOMATIC_PORT) ? port : nil
case .encryptionCipher:
let rawCipher = option as! String
......
......@@ -53,8 +53,8 @@ end
def shared_main_pods
pod 'AlamofireImage'
#library_by_path('..')
library_by_git('ab78a47')
#library_by_version('~> 1.1.1')
#library_by_git('8bc6b90')
library_by_version('~> 1.1.2')
end
def app_pods
......@@ -68,8 +68,8 @@ end
def tunnel_pods
#tunnel_by_path('..')
#tunnel_by_git('9ed3842')
tunnel_by_version('= 1.1.2')
tunnel_by_git('bf89991')
#tunnel_by_version('~> 1.1.3')
end
# Targets
......
......@@ -28,14 +28,14 @@ PODS:
- PIALibrary/Core
- PIALibrary/VPN (1.1.2):
- PIALibrary/Library
- PIATunnel (~> 1.1.2)
- PIATunnel (1.1.2):
- PIATunnel/AppExtension (= 1.1.2)
- PIATunnel/Core (= 1.1.2)
- PIATunnel/AppExtension (1.1.2):
- PIATunnel (~> 1.1.3)
- PIATunnel (1.1.4):
- PIATunnel/AppExtension (= 1.1.4)
- PIATunnel/Core (= 1.1.4)
- PIATunnel/AppExtension (1.1.4):
- PIATunnel/Core
- SwiftyBeaver
- PIATunnel/Core (1.1.2):
- PIATunnel/Core (1.1.4):
- OpenSSL-Apple (~> 1.1.0h)
- SwiftyBeaver
- ReachabilitySwift (4.1.0)
......@@ -49,11 +49,11 @@ DEPENDENCIES:
- HockeySDK
- iRate
- MBProgressHUD
- PIALibrary/Library (from `https://github.com/pia-foss/client-library-apple`, commit `ab78a47`)
- PIALibrary/Mock (from `https://github.com/pia-foss/client-library-apple`, commit `ab78a47`)
- PIALibrary/UI (from `https://github.com/pia-foss/client-library-apple`, commit `ab78a47`)
- PIALibrary/VPN (from `https://github.com/pia-foss/client-library-apple`, commit `ab78a47`)
- PIATunnel (= 1.1.2)
- PIALibrary/Library (~> 1.1.2)
- PIALibrary/Mock (~> 1.1.2)
- PIALibrary/UI (~> 1.1.2)
- PIALibrary/VPN (~> 1.1.2)
- PIATunnel (from `https://github.com/pia-foss/tunnel-apple`, commit `bf89991`)
- SideMenu (= 3.1.5)
- TPKeyboardAvoiding
......@@ -67,21 +67,21 @@ SPEC REPOS:
- iRate
- MBProgressHUD
- OpenSSL-Apple
- PIATunnel
- PIALibrary
- ReachabilitySwift
- SideMenu
- SwiftyBeaver
- TPKeyboardAvoiding
EXTERNAL SOURCES:
PIALibrary:
:commit: ab78a47
:git: https://github.com/pia-foss/client-library-apple
PIATunnel:
:commit: bf89991
:git: https://github.com/pia-foss/tunnel-apple
CHECKOUT OPTIONS:
PIALibrary:
:commit: ab78a47
:git: https://github.com/pia-foss/client-library-apple
PIATunnel:
:commit: bf89991
:git: https://github.com/pia-foss/tunnel-apple
SPEC CHECKSUMS:
Alamofire: e4fa87002c137ba2d8d634d2c51fabcda0d5c223
......@@ -92,13 +92,13 @@ SPEC CHECKSUMS:
iRate: 4fc69958788624545e5d050c8ffd20884013c3f1
MBProgressHUD: e7baa36a220447d8aeb12769bf0585582f3866d9
OpenSSL-Apple: cd153d705ef350eb834ae7ff5f21f792b51ed208
PIALibrary: 42f62b18cd3f135481dc02d2a13714cacb1aa750
PIATunnel: c86cb855e2fb5ad217e6123884ec61fae736636f
PIALibrary: 23b6f2747ba8afc6aaaace1692dd06812fd0fdf6
PIATunnel: fb4bf45efe0a1e4ba9167e0c83238302bc522e7d
ReachabilitySwift: 6849231cd4e06559f3b9ef4a97a0a0f96d41e09f
SideMenu: 47dbf9e4d878062d8994aed43f6e4bf6c1fea30b
SwiftyBeaver: e45759613e50b522b0e6f53b1f0f14389b45ca34
TPKeyboardAvoiding: cb69d5ddbe90ce0170e4bc2db1e5e41d4a3ad9a4
PODFILE CHECKSUM: d8d4cc1ae738a771e2fa5699324e9b4cfa4f6e7b
PODFILE CHECKSUM: 034147692a64641d9ed57530c760c12a5286c76d
COCOAPODS: 1.5.3
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment