Merge branch 'customize-mtu'
This commit is contained in:
commit
4935dc6c39
|
@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Customize MTU in network settings.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Enter explicit Wi-Fi SSID to trust.
|
- Enter explicit Wi-Fi SSID to trust.
|
||||||
|
- Default MTU to 1500.
|
||||||
|
|
||||||
## 1.12.1 (2020-11-15)
|
## 1.12.1 (2020-11-15)
|
||||||
|
|
||||||
|
|
|
@ -600,6 +600,16 @@ internal enum L10n {
|
||||||
/// Default gateway
|
/// Default gateway
|
||||||
internal static let title = L10n.tr("Core", "network_settings.gateway.title")
|
internal static let title = L10n.tr("Core", "network_settings.gateway.title")
|
||||||
}
|
}
|
||||||
|
internal enum Mtu {
|
||||||
|
/// MTU
|
||||||
|
internal static let title = L10n.tr("Core", "network_settings.mtu.title")
|
||||||
|
internal enum Cells {
|
||||||
|
internal enum Bytes {
|
||||||
|
/// Bytes
|
||||||
|
internal static let caption = L10n.tr("Core", "network_settings.mtu.cells.bytes.caption")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
internal enum Proxy {
|
internal enum Proxy {
|
||||||
/// Proxy
|
/// Proxy
|
||||||
internal static let title = L10n.tr("Core", "network_settings.proxy.title")
|
internal static let title = L10n.tr("Core", "network_settings.proxy.title")
|
||||||
|
|
|
@ -82,18 +82,23 @@ class NetworkSettingsViewController: UITableViewController {
|
||||||
if networkChoices.proxy != .server {
|
if networkChoices.proxy != .server {
|
||||||
sections.append(.manualProxy)
|
sections.append(.manualProxy)
|
||||||
}
|
}
|
||||||
|
if networkChoices.mtu != .server {
|
||||||
|
sections.append(.manualMTU)
|
||||||
|
}
|
||||||
|
|
||||||
// headers
|
// headers
|
||||||
model.setHeader("", forSection: .choices)
|
model.setHeader("", forSection: .choices)
|
||||||
model.setHeader(L10n.Core.NetworkSettings.Gateway.title, forSection: .manualGateway)
|
model.setHeader(L10n.Core.NetworkSettings.Gateway.title, forSection: .manualGateway)
|
||||||
model.setHeader(L10n.Core.NetworkSettings.Proxy.title, forSection: .manualProxy)
|
model.setHeader(L10n.Core.NetworkSettings.Proxy.title, forSection: .manualProxy)
|
||||||
|
model.setHeader(L10n.Core.NetworkSettings.Mtu.title, forSection: .manualMTU)
|
||||||
|
|
||||||
// footers
|
// footers
|
||||||
// model.setFooter(L10n.Core.Configuration.Sections.Reset.footer, for: .reset)
|
// model.setFooter(L10n.Core.Configuration.Sections.Reset.footer, for: .reset)
|
||||||
|
|
||||||
// rows
|
// rows
|
||||||
model.set([.gateway, .dns, .proxy], forSection: .choices)
|
model.set([.gateway, .dns, .proxy, .mtu], forSection: .choices)
|
||||||
model.set([.gatewayIPv4, .gatewayIPv6], forSection: .manualGateway)
|
model.set([.gatewayIPv4, .gatewayIPv6], forSection: .manualGateway)
|
||||||
|
model.set([.mtuBytes], forSection: .manualMTU)
|
||||||
|
|
||||||
var dnsServers: [RowType] = Array(repeating: .dnsAddress, count: networkSettings.dnsServers?.count ?? 0)
|
var dnsServers: [RowType] = Array(repeating: .dnsAddress, count: networkSettings.dnsServers?.count ?? 0)
|
||||||
if networkChoices.dns == .manual {
|
if networkChoices.dns == .manual {
|
||||||
|
@ -139,6 +144,7 @@ class NetworkSettingsViewController: UITableViewController {
|
||||||
updateGateway(networkChoices.gateway)
|
updateGateway(networkChoices.gateway)
|
||||||
updateDNS(networkChoices.dns)
|
updateDNS(networkChoices.dns)
|
||||||
updateProxy(networkChoices.proxy)
|
updateProxy(networkChoices.proxy)
|
||||||
|
updateMTU(networkChoices.mtu)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
|
@ -210,6 +216,24 @@ class NetworkSettingsViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func updateMTU(_ choice: NetworkChoice) {
|
||||||
|
networkChoices.mtu = choice
|
||||||
|
switch networkChoices.mtu {
|
||||||
|
case .client:
|
||||||
|
if let settings = clientNetworkSettings {
|
||||||
|
networkSettings.copyMTU(from: settings)
|
||||||
|
}
|
||||||
|
|
||||||
|
case .server:
|
||||||
|
break
|
||||||
|
|
||||||
|
case .manual:
|
||||||
|
if let settings = profile?.manualNetworkSettings {
|
||||||
|
networkSettings.copyMTU(from: settings)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func commitTextField(_ field: UITextField) {
|
private func commitTextField(_ field: UITextField) {
|
||||||
|
|
||||||
// DNS: servers, domains
|
// DNS: servers, domains
|
||||||
|
@ -265,6 +289,9 @@ class NetworkSettingsViewController: UITableViewController {
|
||||||
if networkChoices.proxy == .manual {
|
if networkChoices.proxy == .manual {
|
||||||
settings.copyProxy(from: networkSettings)
|
settings.copyProxy(from: networkSettings)
|
||||||
}
|
}
|
||||||
|
if networkChoices.mtu == .manual {
|
||||||
|
settings.copyMTU(from: networkSettings)
|
||||||
|
}
|
||||||
profile?.manualNetworkSettings = settings
|
profile?.manualNetworkSettings = settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,6 +309,8 @@ extension NetworkSettingsViewController {
|
||||||
case manualDNSDomains
|
case manualDNSDomains
|
||||||
|
|
||||||
case manualProxy
|
case manualProxy
|
||||||
|
|
||||||
|
case manualMTU
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RowType: Int {
|
enum RowType: Int {
|
||||||
|
@ -291,6 +320,8 @@ extension NetworkSettingsViewController {
|
||||||
|
|
||||||
case proxy
|
case proxy
|
||||||
|
|
||||||
|
case mtu
|
||||||
|
|
||||||
case gatewayIPv4
|
case gatewayIPv4
|
||||||
|
|
||||||
case gatewayIPv6
|
case gatewayIPv6
|
||||||
|
@ -312,6 +343,8 @@ extension NetworkSettingsViewController {
|
||||||
case proxyBypass
|
case proxyBypass
|
||||||
|
|
||||||
case proxyAddBypass
|
case proxyAddBypass
|
||||||
|
|
||||||
|
case mtuBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||||
|
@ -356,6 +389,12 @@ extension NetworkSettingsViewController {
|
||||||
cell.rightText = networkChoices.proxy.description
|
cell.rightText = networkChoices.proxy.description
|
||||||
return cell
|
return cell
|
||||||
|
|
||||||
|
case .mtu:
|
||||||
|
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
|
||||||
|
cell.leftText = L10n.Core.NetworkSettings.Mtu.title
|
||||||
|
cell.rightText = networkChoices.mtu.description
|
||||||
|
return cell
|
||||||
|
|
||||||
case .gatewayIPv4:
|
case .gatewayIPv4:
|
||||||
let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self)
|
let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self)
|
||||||
cell.caption = "IPv4"
|
cell.caption = "IPv4"
|
||||||
|
@ -471,6 +510,12 @@ extension NetworkSettingsViewController {
|
||||||
cell.applyAction(.current)
|
cell.applyAction(.current)
|
||||||
cell.leftText = L10n.App.NetworkSettings.Cells.AddProxyBypass.caption
|
cell.leftText = L10n.App.NetworkSettings.Cells.AddProxyBypass.caption
|
||||||
return cell
|
return cell
|
||||||
|
|
||||||
|
case .mtuBytes:
|
||||||
|
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
|
||||||
|
cell.leftText = L10n.Core.NetworkSettings.Mtu.Cells.Bytes.caption
|
||||||
|
cell.rightText = networkSettings.mtuBytes?.description ?? "Default"
|
||||||
|
return cell
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,6 +565,20 @@ extension NetworkSettingsViewController {
|
||||||
}
|
}
|
||||||
navigationController?.pushViewController(vc, animated: true)
|
navigationController?.pushViewController(vc, animated: true)
|
||||||
|
|
||||||
|
case .mtu:
|
||||||
|
let vc = SingleOptionViewController<NetworkChoice>()
|
||||||
|
vc.applyTint(.current)
|
||||||
|
vc.title = (cell as? SettingTableViewCell)?.leftText
|
||||||
|
vc.options = NetworkChoice.choices(for: profile)
|
||||||
|
vc.descriptionBlock = { $0.description }
|
||||||
|
|
||||||
|
vc.selectedOption = networkChoices.mtu
|
||||||
|
vc.selectionBlock = { [weak self] in
|
||||||
|
self?.updateMTU($0)
|
||||||
|
self?.navigationController?.popViewController(animated: true)
|
||||||
|
}
|
||||||
|
navigationController?.pushViewController(vc, animated: true)
|
||||||
|
|
||||||
case .dnsAddAddress:
|
case .dnsAddAddress:
|
||||||
tableView.deselectRow(at: indexPath, animated: true)
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
|
|
||||||
|
@ -547,6 +606,23 @@ extension NetworkSettingsViewController {
|
||||||
reloadModel()
|
reloadModel()
|
||||||
tableView.insertRows(at: [indexPath], with: .automatic)
|
tableView.insertRows(at: [indexPath], with: .automatic)
|
||||||
|
|
||||||
|
case .mtuBytes:
|
||||||
|
guard networkChoices.mtu == .manual else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
let vc = SingleOptionViewController<Int>()
|
||||||
|
vc.applyTint(.current)
|
||||||
|
vc.title = (cell as? SettingTableViewCell)?.leftText
|
||||||
|
vc.options = ProfileNetworkSettings.mtuOptions
|
||||||
|
vc.descriptionBlock = { $0.description }
|
||||||
|
|
||||||
|
vc.selectedOption = networkSettings.mtuBytes
|
||||||
|
vc.selectionBlock = { [weak self] in
|
||||||
|
self?.networkSettings.mtuBytes = $0
|
||||||
|
self?.navigationController?.popViewController(animated: true)
|
||||||
|
}
|
||||||
|
navigationController?.pushViewController(vc, animated: true)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
2
Podfile
2
Podfile
|
@ -9,7 +9,7 @@ $tunnelkit_specs = ['Protocols/OpenVPN', 'Extra/LZO']
|
||||||
|
|
||||||
def shared_pods
|
def shared_pods
|
||||||
#pod_version $tunnelkit_name, $tunnelkit_specs, '~> 3.0.1'
|
#pod_version $tunnelkit_name, $tunnelkit_specs, '~> 3.0.1'
|
||||||
pod_git $tunnelkit_name, $tunnelkit_specs, 'ba3ead1'
|
pod_git $tunnelkit_name, $tunnelkit_specs, 'e923382'
|
||||||
#pod_path $tunnelkit_name, $tunnelkit_specs, '..'
|
#pod_path $tunnelkit_name, $tunnelkit_specs, '..'
|
||||||
pod 'SSZipArchive'
|
pod 'SSZipArchive'
|
||||||
|
|
||||||
|
|
10
Podfile.lock
10
Podfile.lock
|
@ -52,8 +52,8 @@ DEPENDENCIES:
|
||||||
- Kvitto
|
- Kvitto
|
||||||
- MBProgressHUD
|
- MBProgressHUD
|
||||||
- SSZipArchive
|
- SSZipArchive
|
||||||
- TunnelKit/Extra/LZO (from `https://github.com/passepartoutvpn/tunnelkit`, commit `ba3ead1`)
|
- TunnelKit/Extra/LZO (from `https://github.com/passepartoutvpn/tunnelkit`, commit `e923382`)
|
||||||
- TunnelKit/Protocols/OpenVPN (from `https://github.com/passepartoutvpn/tunnelkit`, commit `ba3ead1`)
|
- TunnelKit/Protocols/OpenVPN (from `https://github.com/passepartoutvpn/tunnelkit`, commit `e923382`)
|
||||||
|
|
||||||
SPEC REPOS:
|
SPEC REPOS:
|
||||||
https://github.com/cocoapods/specs.git:
|
https://github.com/cocoapods/specs.git:
|
||||||
|
@ -69,7 +69,7 @@ EXTERNAL SOURCES:
|
||||||
:commit: b30816a
|
:commit: b30816a
|
||||||
:git: https://github.com/keeshux/convenience
|
:git: https://github.com/keeshux/convenience
|
||||||
TunnelKit:
|
TunnelKit:
|
||||||
:commit: ba3ead1
|
:commit: e923382
|
||||||
:git: https://github.com/passepartoutvpn/tunnelkit
|
:git: https://github.com/passepartoutvpn/tunnelkit
|
||||||
|
|
||||||
CHECKOUT OPTIONS:
|
CHECKOUT OPTIONS:
|
||||||
|
@ -77,7 +77,7 @@ CHECKOUT OPTIONS:
|
||||||
:commit: b30816a
|
:commit: b30816a
|
||||||
:git: https://github.com/keeshux/convenience
|
:git: https://github.com/keeshux/convenience
|
||||||
TunnelKit:
|
TunnelKit:
|
||||||
:commit: ba3ead1
|
:commit: e923382
|
||||||
:git: https://github.com/passepartoutvpn/tunnelkit
|
:git: https://github.com/passepartoutvpn/tunnelkit
|
||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
|
@ -90,6 +90,6 @@ SPEC CHECKSUMS:
|
||||||
SwiftyBeaver: 2e8acd6fc90c6d0a27055867a290794926d57c02
|
SwiftyBeaver: 2e8acd6fc90c6d0a27055867a290794926d57c02
|
||||||
TunnelKit: 4db9180956f8aaf4ab152fd0d38c6c9c63a46cf8
|
TunnelKit: 4db9180956f8aaf4ab152fd0d38c6c9c63a46cf8
|
||||||
|
|
||||||
PODFILE CHECKSUM: 96b84a3adcf28988f3e33ddb5110dc243dd7fefe
|
PODFILE CHECKSUM: 18150cf5ff4c6f87ae8ecd29ddbea7d64d6741bd
|
||||||
|
|
||||||
COCOAPODS: 1.10.0
|
COCOAPODS: 1.10.0
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 20d5067282d2955b68a47b19531ab439aad3c28b
|
Subproject commit b8d72f3e58158dc185b34ac135d16837be28e5d1
|
Loading…
Reference in New Issue