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
|
||||
|
||||
### Added
|
||||
|
||||
- Customize MTU in network settings.
|
||||
|
||||
### Changed
|
||||
|
||||
- Enter explicit Wi-Fi SSID to trust.
|
||||
- Default MTU to 1500.
|
||||
|
||||
## 1.12.1 (2020-11-15)
|
||||
|
||||
|
|
|
@ -600,6 +600,16 @@ internal enum L10n {
|
|||
/// Default gateway
|
||||
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 {
|
||||
/// Proxy
|
||||
internal static let title = L10n.tr("Core", "network_settings.proxy.title")
|
||||
|
|
|
@ -82,18 +82,23 @@ class NetworkSettingsViewController: UITableViewController {
|
|||
if networkChoices.proxy != .server {
|
||||
sections.append(.manualProxy)
|
||||
}
|
||||
if networkChoices.mtu != .server {
|
||||
sections.append(.manualMTU)
|
||||
}
|
||||
|
||||
// headers
|
||||
model.setHeader("", forSection: .choices)
|
||||
model.setHeader(L10n.Core.NetworkSettings.Gateway.title, forSection: .manualGateway)
|
||||
model.setHeader(L10n.Core.NetworkSettings.Proxy.title, forSection: .manualProxy)
|
||||
model.setHeader(L10n.Core.NetworkSettings.Mtu.title, forSection: .manualMTU)
|
||||
|
||||
// footers
|
||||
// model.setFooter(L10n.Core.Configuration.Sections.Reset.footer, for: .reset)
|
||||
|
||||
// rows
|
||||
model.set([.gateway, .dns, .proxy], forSection: .choices)
|
||||
model.set([.gateway, .dns, .proxy, .mtu], forSection: .choices)
|
||||
model.set([.gatewayIPv4, .gatewayIPv6], forSection: .manualGateway)
|
||||
model.set([.mtuBytes], forSection: .manualMTU)
|
||||
|
||||
var dnsServers: [RowType] = Array(repeating: .dnsAddress, count: networkSettings.dnsServers?.count ?? 0)
|
||||
if networkChoices.dns == .manual {
|
||||
|
@ -139,6 +144,7 @@ class NetworkSettingsViewController: UITableViewController {
|
|||
updateGateway(networkChoices.gateway)
|
||||
updateDNS(networkChoices.dns)
|
||||
updateProxy(networkChoices.proxy)
|
||||
updateMTU(networkChoices.mtu)
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
// DNS: servers, domains
|
||||
|
@ -265,6 +289,9 @@ class NetworkSettingsViewController: UITableViewController {
|
|||
if networkChoices.proxy == .manual {
|
||||
settings.copyProxy(from: networkSettings)
|
||||
}
|
||||
if networkChoices.mtu == .manual {
|
||||
settings.copyMTU(from: networkSettings)
|
||||
}
|
||||
profile?.manualNetworkSettings = settings
|
||||
}
|
||||
}
|
||||
|
@ -282,6 +309,8 @@ extension NetworkSettingsViewController {
|
|||
case manualDNSDomains
|
||||
|
||||
case manualProxy
|
||||
|
||||
case manualMTU
|
||||
}
|
||||
|
||||
enum RowType: Int {
|
||||
|
@ -291,6 +320,8 @@ extension NetworkSettingsViewController {
|
|||
|
||||
case proxy
|
||||
|
||||
case mtu
|
||||
|
||||
case gatewayIPv4
|
||||
|
||||
case gatewayIPv6
|
||||
|
@ -312,6 +343,8 @@ extension NetworkSettingsViewController {
|
|||
case proxyBypass
|
||||
|
||||
case proxyAddBypass
|
||||
|
||||
case mtuBytes
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
|
@ -356,6 +389,12 @@ extension NetworkSettingsViewController {
|
|||
cell.rightText = networkChoices.proxy.description
|
||||
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:
|
||||
let cell = Cells.toggle.dequeue(from: tableView, for: indexPath, tag: row.rawValue, delegate: self)
|
||||
cell.caption = "IPv4"
|
||||
|
@ -471,6 +510,12 @@ extension NetworkSettingsViewController {
|
|||
cell.applyAction(.current)
|
||||
cell.leftText = L10n.App.NetworkSettings.Cells.AddProxyBypass.caption
|
||||
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)
|
||||
|
||||
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:
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
|
||||
|
@ -547,6 +606,23 @@ extension NetworkSettingsViewController {
|
|||
reloadModel()
|
||||
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:
|
||||
break
|
||||
}
|
||||
|
|
2
Podfile
2
Podfile
|
@ -9,7 +9,7 @@ $tunnelkit_specs = ['Protocols/OpenVPN', 'Extra/LZO']
|
|||
|
||||
def shared_pods
|
||||
#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 'SSZipArchive'
|
||||
|
||||
|
|
10
Podfile.lock
10
Podfile.lock
|
@ -52,8 +52,8 @@ DEPENDENCIES:
|
|||
- Kvitto
|
||||
- MBProgressHUD
|
||||
- SSZipArchive
|
||||
- TunnelKit/Extra/LZO (from `https://github.com/passepartoutvpn/tunnelkit`, commit `ba3ead1`)
|
||||
- TunnelKit/Protocols/OpenVPN (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 `e923382`)
|
||||
|
||||
SPEC REPOS:
|
||||
https://github.com/cocoapods/specs.git:
|
||||
|
@ -69,7 +69,7 @@ EXTERNAL SOURCES:
|
|||
:commit: b30816a
|
||||
:git: https://github.com/keeshux/convenience
|
||||
TunnelKit:
|
||||
:commit: ba3ead1
|
||||
:commit: e923382
|
||||
:git: https://github.com/passepartoutvpn/tunnelkit
|
||||
|
||||
CHECKOUT OPTIONS:
|
||||
|
@ -77,7 +77,7 @@ CHECKOUT OPTIONS:
|
|||
:commit: b30816a
|
||||
:git: https://github.com/keeshux/convenience
|
||||
TunnelKit:
|
||||
:commit: ba3ead1
|
||||
:commit: e923382
|
||||
:git: https://github.com/passepartoutvpn/tunnelkit
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
|
@ -90,6 +90,6 @@ SPEC CHECKSUMS:
|
|||
SwiftyBeaver: 2e8acd6fc90c6d0a27055867a290794926d57c02
|
||||
TunnelKit: 4db9180956f8aaf4ab152fd0d38c6c9c63a46cf8
|
||||
|
||||
PODFILE CHECKSUM: 96b84a3adcf28988f3e33ddb5110dc243dd7fefe
|
||||
PODFILE CHECKSUM: 18150cf5ff4c6f87ae8ecd29ddbea7d64d6741bd
|
||||
|
||||
COCOAPODS: 1.10.0
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 20d5067282d2955b68a47b19531ab439aad3c28b
|
||||
Subproject commit b8d72f3e58158dc185b34ac135d16837be28e5d1
|
Loading…
Reference in New Issue