Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reflect obfuscation protocol in UI ios 398 #5548

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ios/MullvadTypes/TransportLayer.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// TransportLayer.swift
// MullvadTypes
//
// Created by Marco Nikic on 2023-11-24.
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//

import Foundation

public enum TransportLayer: Codable {
case udp
case tcp
}
23 changes: 23 additions & 0 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,9 @@
A900E9BC2ACC609200C95F67 /* DevicesProxy+Stubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = A900E9BB2ACC609200C95F67 /* DevicesProxy+Stubs.swift */; };
A900E9BE2ACC654100C95F67 /* APIProxy+Stubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = A900E9BD2ACC654100C95F67 /* APIProxy+Stubs.swift */; };
A900E9C02ACC661900C95F67 /* AccessTokenManager+Stubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = A900E9BF2ACC661900C95F67 /* AccessTokenManager+Stubs.swift */; };
A91614D12B108D1B00F416EB /* TransportLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A91614D02B108D1B00F416EB /* TransportLayer.swift */; };
A91614D42B108F5600F416EB /* MullvadTypes.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58D223D5294C8E5E0029F5F8 /* MullvadTypes.framework */; };
A91614D62B10B26B00F416EB /* TunnelControlViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A91614D52B10B26B00F416EB /* TunnelControlViewModel.swift */; };
A917352129FAAA5200D5DCFD /* TransportStrategyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A917352029FAAA5200D5DCFD /* TransportStrategyTests.swift */; };
A91D78E32B03BDF200FCD5D3 /* TunnelObfuscation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5840231F2A406BF5007B27AC /* TunnelObfuscation.framework */; };
A91D78E42B03C01600FCD5D3 /* MullvadSettings.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58B2FDD32AA71D2A003EB5C6 /* MullvadSettings.framework */; };
Expand Down Expand Up @@ -985,6 +988,13 @@
remoteGlobalIDString = 7A88DCCD2A8FABBE00D2FF0E;
remoteInfo = Routing;
};
A91614D22B108F4D00F416EB /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 58CE5E58224146200008646E /* Project object */;
proxyType = 1;
remoteGlobalIDString = 58D223D4294C8E5E0029F5F8;
remoteInfo = MullvadTypes;
};
A91D78E12B03BDE500FCD5D3 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 58CE5E58224146200008646E /* Project object */;
Expand Down Expand Up @@ -1620,6 +1630,8 @@
A900E9BB2ACC609200C95F67 /* DevicesProxy+Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DevicesProxy+Stubs.swift"; sourceTree = "<group>"; };
A900E9BD2ACC654100C95F67 /* APIProxy+Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "APIProxy+Stubs.swift"; sourceTree = "<group>"; };
A900E9BF2ACC661900C95F67 /* AccessTokenManager+Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AccessTokenManager+Stubs.swift"; sourceTree = "<group>"; };
A91614D02B108D1B00F416EB /* TransportLayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransportLayer.swift; sourceTree = "<group>"; };
A91614D52B10B26B00F416EB /* TunnelControlViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelControlViewModel.swift; sourceTree = "<group>"; };
A917352029FAAA5200D5DCFD /* TransportStrategyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransportStrategyTests.swift; sourceTree = "<group>"; };
A92962582B1F4FDB00DFB93B /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
A92ECC202A77FFAF0052F1B1 /* TunnelSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelSettings.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1724,6 +1736,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A91614D42B108F5600F416EB /* MullvadTypes.framework in Frameworks */,
584023292A407F5F007B27AC /* libtunnel_obfuscator_proxy.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -2005,6 +2018,7 @@
581DA2722A1E227D0046ED47 /* RESTTypes.swift */,
58F1311427E0B2AB007AC5BC /* Result+Extensions.swift */,
58E511E028DDB7F100B0BCDE /* WrappingError.swift */,
A91614D02B108D1B00F416EB /* TransportLayer.swift */,
);
path = MullvadTypes;
sourceTree = "<group>";
Expand Down Expand Up @@ -2186,6 +2200,7 @@
58B43C1825F77DB60002C8C3 /* TunnelControlView.swift */,
58CCA00F224249A1004F3011 /* TunnelViewController.swift */,
5878A278290954790096FC88 /* TunnelViewControllerInteractor.swift */,
A91614D52B10B26B00F416EB /* TunnelControlViewModel.swift */,
);
path = Tunnel;
sourceTree = "<group>";
Expand Down Expand Up @@ -3307,6 +3322,7 @@
buildRules = (
);
dependencies = (
A91614D32B108F4D00F416EB /* PBXTargetDependency */,
);
name = TunnelObfuscation;
productName = TunnelObfuscator;
Expand Down Expand Up @@ -4413,6 +4429,7 @@
58B26E2A2943545A00D5980C /* NotificationManagerDelegate.swift in Sources */,
58A1AA8C23F5584C009F7EA6 /* ConnectionPanelView.swift in Sources */,
5878A27B2909649A0096FC88 /* CustomOverlayRenderer.swift in Sources */,
A91614D62B10B26B00F416EB /* TunnelControlViewModel.swift in Sources */,
588527B2276B3F0700BAA373 /* LoadTunnelConfigurationOperation.swift in Sources */,
7AF9BE992A4E0FE900DBFEDB /* MarkdownStylingOptions.swift in Sources */,
5867770E29096984006F721F /* OutOfTimeInteractor.swift in Sources */,
Expand Down Expand Up @@ -4685,6 +4702,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A91614D12B108D1B00F416EB /* TransportLayer.swift in Sources */,
58D22406294C90210029F5F8 /* IPv4Endpoint.swift in Sources */,
7A307ADB2A8F56DF0017618B /* Duration+Extensions.swift in Sources */,
58D22407294C90210029F5F8 /* IPv6Endpoint.swift in Sources */,
Expand Down Expand Up @@ -4999,6 +5017,11 @@
target = 7A88DCCD2A8FABBE00D2FF0E /* Routing */;
targetProxy = 7ABCA5B52A9349F20044A708 /* PBXContainerItemProxy */;
};
A91614D32B108F4D00F416EB /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 58D223D4294C8E5E0029F5F8 /* MullvadTypes */;
targetProxy = A91614D22B108F4D00F416EB /* PBXContainerItemProxy */;
};
A91D78E22B03BDE500FCD5D3 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 5840231E2A406BF5007B27AC /* TunnelObfuscation */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ final class SimulatorTunnelProviderHost: SimulatorTunnelProviderDelegate {
selectedRelay: selectedRelay,
relayConstraints: try SettingsManager.readSettings().relayConstraints,
networkReachability: .reachable,
connectionAttemptCount: 0
connectionAttemptCount: 0,
transportLayer: .udp,
remotePort: selectedRelay.endpoint.ipv4Relay.port
)
)
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ final class PreferencesCellFactory: CellFactoryProtocol {
}
}

#if DEBUG
case .wireGuardObfuscationAutomatic:
guard let cell = cell as? SelectableSettingsCell else { return }

Expand Down Expand Up @@ -157,7 +156,6 @@ final class PreferencesCellFactory: CellFactoryProtocol {
)
cell.accessibilityHint = nil
cell.applySubCellStyling()
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
case dnsSettings
case wireGuardPort
case wireGuardCustomPort
#if DEBUG
case wireGuardObfuscation
case wireGuardObfuscationPort
#endif
var reusableViewClass: AnyClass {
switch self {
case .dnsSettings:
Expand All @@ -31,12 +29,10 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
return SelectableSettingsCell.self
case .wireGuardCustomPort:
return SettingsInputCell.self
#if DEBUG
case .wireGuardObfuscation:
return SelectableSettingsCell.self
case .wireGuardObfuscationPort:
return SelectableSettingsCell.self
#endif
}
}
}
Expand All @@ -52,22 +48,18 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
enum Section: String, Hashable, CaseIterable {
case dnsSettings
case wireGuardPorts
#if DEBUG
case wireGuardObfuscation
case wireGuardObfuscationPort
#endif
}

enum Item: Hashable {
case dnsSettings
case wireGuardPort(_ port: UInt16?)
case wireGuardCustomPort
#if DEBUG
case wireGuardObfuscationAutomatic
case wireGuardObfuscationOn
case wireGuardObfuscationOff
case wireGuardObfuscationPort(_ port: UInt16)
#endif

static var wireGuardPorts: [Item] {
let defaultPorts = PreferencesViewModel.defaultWireGuardPorts.map {
Expand All @@ -76,15 +68,14 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
return [.wireGuardPort(nil)] + defaultPorts + [.wireGuardCustomPort]
}

#if DEBUG
static var wireGuardObfuscation: [Item] {
[.wireGuardObfuscationAutomatic, .wireGuardObfuscationOn, wireGuardObfuscationOff]
}

static var wireGuardObfuscationPort: [Item] {
[.wireGuardObfuscationPort(0), wireGuardObfuscationPort(80), wireGuardObfuscationPort(5001)]
}
#endif

var accessibilityIdentifier: String {
switch self {
case .dnsSettings:
Expand All @@ -97,7 +88,6 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
}
case .wireGuardCustomPort:
return "wireGuardCustomPort"
#if DEBUG
case .wireGuardObfuscationAutomatic:
return "Automatic"
case .wireGuardObfuscationOn:
Expand All @@ -109,7 +99,6 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
return "Automatic"
}
return "\(port)"
#endif
}
}

Expand All @@ -121,12 +110,10 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
return .wireGuardPort
case .wireGuardCustomPort:
return .wireGuardCustomPort
#if DEBUG
case .wireGuardObfuscationAutomatic, .wireGuardObfuscationOn, .wireGuardObfuscationOff:
return .wireGuardObfuscation
case .wireGuardObfuscationPort:
return .wireGuardObfuscationPort
#endif
}
}
}
Expand All @@ -144,7 +131,6 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
? .wireGuardPort(viewModel.wireGuardPort)
: .wireGuardCustomPort

#if DEBUG
let obfuscationStateItem: Item = switch viewModel.obfuscationState {
case .automatic: .wireGuardObfuscationAutomatic
case .off: .wireGuardObfuscationOff
Expand All @@ -158,11 +144,6 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
indexPath(for: obfuscationStateItem),
indexPath(for: obfuscationPortItem),
].compactMap { $0 }
#else
return [
indexPath(for: wireGuardPortItem),
].compactMap { $0 }
#endif
}

init(tableView: UITableView) {
Expand Down Expand Up @@ -254,7 +235,6 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
case .wireGuardCustomPort:
getCustomPortCell()?.textField.becomeFirstResponder()

#if DEBUG
case .wireGuardObfuscationAutomatic:
selectObfuscationState(.automatic)
delegate?.didChangeViewModel(viewModel)
Expand All @@ -267,7 +247,6 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
case let .wireGuardObfuscationPort(port):
selectObfuscationPort(port)
delegate?.didChangeViewModel(viewModel)
#endif
default:
break
}
Expand Down Expand Up @@ -299,14 +278,12 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
configureWireguardPortsHeader(view)
return view

#if DEBUG
case .wireGuardObfuscation:
configureObfuscationHeader(view)
return view
case .wireGuardObfuscationPort:
configureObfuscationPortHeader(view)
return view
#endif
default:
return nil
}
Expand Down Expand Up @@ -433,7 +410,6 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
}
}

#if DEBUG
private func configureObfuscationHeader(_ header: SettingsHeaderView) {
let title = NSLocalizedString(
"OBFUSCATION_HEADER_LABEL",
Expand Down Expand Up @@ -489,7 +465,6 @@ final class PreferencesDataSource: UITableViewDiffableDataSource<
self.map { $0.delegate?.showInfo(for: .wireGuardObfuscationPort) }
}
}
#endif

private func selectRow(at indexPath: IndexPath?, animated: Bool = false) {
tableView?.selectRow(at: indexPath, animated: animated, scrollPosition: .none)
Expand Down
Loading
Loading