From 9d6a2cbd6450b532955f129188022abf60f86c67 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 28 Dec 2020 08:07:36 +0100 Subject: [PATCH 1/4] Refactor MTU in TunnelKit --- Podfile | 2 +- Podfile.lock | 10 +++++----- Submodules/Core | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Podfile b/Podfile index 30cd668d..0b3587f7 100644 --- a/Podfile +++ b/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' diff --git a/Podfile.lock b/Podfile.lock index 3b934590..3667d1d6 100644 --- a/Podfile.lock +++ b/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 diff --git a/Submodules/Core b/Submodules/Core index 20d50672..9f2c220b 160000 --- a/Submodules/Core +++ b/Submodules/Core @@ -1 +1 @@ -Subproject commit 20d5067282d2955b68a47b19531ab439aad3c28b +Subproject commit 9f2c220bf566cf1c79115eef6d6708ce9d487f95 From a773ffd9429e58e8bbe71d1f32cc30d019dac70b Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 28 Dec 2020 15:04:24 +0100 Subject: [PATCH 2/4] Add section to customize MTU --- .../Global/SwiftGen+Strings.swift | 10 +++ .../NetworkSettingsViewController.swift | 78 ++++++++++++++++++- Submodules/Core | 2 +- 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/Passepartout-iOS/Global/SwiftGen+Strings.swift b/Passepartout-iOS/Global/SwiftGen+Strings.swift index 5c7de3fa..72f8373b 100644 --- a/Passepartout-iOS/Global/SwiftGen+Strings.swift +++ b/Passepartout-iOS/Global/SwiftGen+Strings.swift @@ -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") diff --git a/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift b/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift index efd6c685..f322d16d 100644 --- a/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift +++ b/Passepartout-iOS/Scenes/NetworkSettingsViewController.swift @@ -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 { @@ -355,6 +388,12 @@ extension NetworkSettingsViewController { cell.leftText = L10n.Core.NetworkSettings.Proxy.title 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) @@ -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() + 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() + 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 } diff --git a/Submodules/Core b/Submodules/Core index 9f2c220b..2358fc83 160000 --- a/Submodules/Core +++ b/Submodules/Core @@ -1 +1 @@ -Subproject commit 9f2c220bf566cf1c79115eef6d6708ce9d487f95 +Subproject commit 2358fc8332da87ea3d37f0d78e1727b1b427dd43 From af874a50ceb688a3a48ae251b7bd2d0589bf9a88 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 28 Dec 2020 18:22:09 +0100 Subject: [PATCH 3/4] Add localized strings --- Submodules/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Submodules/Core b/Submodules/Core index 2358fc83..b8d72f3e 160000 --- a/Submodules/Core +++ b/Submodules/Core @@ -1 +1 @@ -Subproject commit 2358fc8332da87ea3d37f0d78e1727b1b427dd43 +Subproject commit b8d72f3e58158dc185b34ac135d16837be28e5d1 From 991fefc0b3006b8c455e921fe7aee18b67551ece Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 28 Dec 2020 18:22:14 +0100 Subject: [PATCH 4/4] Update CHANGELOG --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index acd1f6cc..a880db88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)