Skip to content

Commit

Permalink
Merge branch 'fix-swiftlint-warnings-in-xcode-ios-SimulatorTunnel-296'
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Sep 8, 2023
2 parents 97a10b1 + 7cc3621 commit 4fc842f
Show file tree
Hide file tree
Showing 5 changed files with 369 additions and 326 deletions.
12 changes: 12 additions & 0 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@
7A21DACF2A30AA3700A787A9 /* UITextField+Appearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A21DACE2A30AA3700A787A9 /* UITextField+Appearance.swift */; };
7A307AD92A8CD8DA0017618B /* Duration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A307AD82A8CD8DA0017618B /* Duration.swift */; };
7A307ADB2A8F56DF0017618B /* Duration+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A307ADA2A8F56DF0017618B /* Duration+Extensions.swift */; };
7A33538F2AA9FF1600F0A71C /* SimulatorTunnelProviderManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A33538E2AA9FF1600F0A71C /* SimulatorTunnelProviderManager.swift */; };
7A3353912AAA014400F0A71C /* SimulatorVPNConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A3353902AAA014400F0A71C /* SimulatorVPNConnection.swift */; };
7A3353932AAA089000F0A71C /* SimulatorTunnelInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A3353922AAA089000F0A71C /* SimulatorTunnelInfo.swift */; };
7A3353972AAA0F8600F0A71C /* OperationBlockObserverSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A3353962AAA0F8600F0A71C /* OperationBlockObserverSupport.swift */; };
7A42DEC92A05164100B209BE /* SettingsInputCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A42DEC82A05164100B209BE /* SettingsInputCell.swift */; };
7A42DECD2A09064C00B209BE /* SelectableSettingsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A42DECC2A09064C00B209BE /* SelectableSettingsCell.swift */; };
Expand Down Expand Up @@ -1312,6 +1315,9 @@
7A21DACE2A30AA3700A787A9 /* UITextField+Appearance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITextField+Appearance.swift"; sourceTree = "<group>"; };
7A307AD82A8CD8DA0017618B /* Duration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Duration.swift; sourceTree = "<group>"; };
7A307ADA2A8F56DF0017618B /* Duration+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Duration+Extensions.swift"; sourceTree = "<group>"; };
7A33538E2AA9FF1600F0A71C /* SimulatorTunnelProviderManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimulatorTunnelProviderManager.swift; sourceTree = "<group>"; };
7A3353902AAA014400F0A71C /* SimulatorVPNConnection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimulatorVPNConnection.swift; sourceTree = "<group>"; };
7A3353922AAA089000F0A71C /* SimulatorTunnelInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimulatorTunnelInfo.swift; sourceTree = "<group>"; };
7A3353962AAA0F8600F0A71C /* OperationBlockObserverSupport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationBlockObserverSupport.swift; sourceTree = "<group>"; };
7A42DEC82A05164100B209BE /* SettingsInputCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsInputCell.swift; sourceTree = "<group>"; };
7A42DECC2A09064C00B209BE /* SelectableSettingsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectableSettingsCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1985,8 +1991,11 @@
583FE02629C1ADB6006E85F9 /* SimulatorTunnelProvider */ = {
isa = PBXGroup;
children = (
7A3353922AAA089000F0A71C /* SimulatorTunnelInfo.swift */,
58BA693023EADA6A009DC256 /* SimulatorTunnelProvider.swift */,
587A01FB23F1F0BE00B68763 /* SimulatorTunnelProviderHost.swift */,
7A33538E2AA9FF1600F0A71C /* SimulatorTunnelProviderManager.swift */,
7A3353902AAA014400F0A71C /* SimulatorVPNConnection.swift */,
);
path = SimulatorTunnelProvider;
sourceTree = "<group>";
Expand Down Expand Up @@ -3736,6 +3745,7 @@
587988C728A2A01F00E3DF54 /* AccountDataThrottling.swift in Sources */,
F04FBE612A8379EE009278D7 /* AppPreferences.swift in Sources */,
5896CEF226972DEB00B0FAE8 /* AccountContentView.swift in Sources */,
7A3353932AAA089000F0A71C /* SimulatorTunnelInfo.swift in Sources */,
5867771429097BCD006F721F /* PaymentState.swift in Sources */,
F0EF50D32A8FA47E0031E8DF /* ChangeLogInteractor.swift in Sources */,
F0C2AEFD2A0BB5CC00986207 /* NotificationProviderIdentifier.swift in Sources */,
Expand Down Expand Up @@ -3835,6 +3845,7 @@
585CA70F25F8C44600B47C62 /* UIMetrics.swift in Sources */,
E1187ABD289BBB850024E748 /* OutOfTimeContentView.swift in Sources */,
58CC40EF24A601900019D96E /* ObserverList.swift in Sources */,
7A33538F2AA9FF1600F0A71C /* SimulatorTunnelProviderManager.swift in Sources */,
7A1A26432A2612AE00B978AA /* PaymentAlertPresenter.swift in Sources */,
7A9CCCBB2A96302800DD6A34 /* InAppPurchaseCoordinator.swift in Sources */,
58CCA01822426713004F3011 /* AccountViewController.swift in Sources */,
Expand Down Expand Up @@ -3868,6 +3879,7 @@
5888AD83227B11080051EB06 /* SelectLocationCell.swift in Sources */,
5891BF1C25E3E3EB006D6FB0 /* Bundle+ProductVersion.swift in Sources */,
5878A26F2907E7E00096FC88 /* ProblemReportInteractor.swift in Sources */,
7A3353912AAA014400F0A71C /* SimulatorVPNConnection.swift in Sources */,
7AE47E522A17972A000418DA /* CustomAlertViewController.swift in Sources */,
F028A56A2A34D4E700C0CAA3 /* RedeemVoucherViewController.swift in Sources */,
58E11188292FA11F009FCA84 /* SettingsMigrationUIHandler.swift in Sources */,
Expand Down
56 changes: 56 additions & 0 deletions ios/MullvadVPN/SimulatorTunnelProvider/SimulatorTunnelInfo.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// SimulatorTunnelInfo.swift
// MullvadVPN
//
// Created by Jon Petersson on 2023-09-07.
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//

#if targetEnvironment(simulator)

import Foundation
import NetworkExtension

final class SimulatorTunnelProviderSession: SimulatorVPNConnection, VPNTunnelProviderSessionProtocol {
func sendProviderMessage(_ messageData: Data, responseHandler: ((Data?) -> Void)?) throws {
SimulatorTunnelProvider.shared.handleAppMessage(
messageData,
completionHandler: responseHandler
)
}
}

/// A mock struct for tunnel configuration and connection
struct SimulatorTunnelInfo {
/// A unique identifier for the configuration
var identifier = UUID().uuidString

/// An associated VPN connection.
/// Intentionally initialized with a `SimulatorTunnelProviderSession` subclass which
/// implements the necessary protocol
var connection: SimulatorVPNConnection = SimulatorTunnelProviderSession()

/// Whether configuration is enabled
var isEnabled = false

/// Whether on-demand VPN is enabled
var isOnDemandEnabled = false

/// On-demand VPN rules
var onDemandRules = [NEOnDemandRule]()

/// Protocol configuration
var protocolConfiguration: NEVPNProtocol? {
didSet {
connection.protocolConfiguration = protocolConfiguration ?? NEVPNProtocol()
}
}

/// Tunnel description
var localizedDescription: String?

/// Designated initializer
init() {}
}

#endif
Loading

0 comments on commit 4fc842f

Please sign in to comment.