Move VPN.shared from TunnelKit to Core

Start moving legacy out of inner library.
This commit is contained in:
Davide De Rosa 2021-09-20 19:48:23 +02:00
parent f9e9df0e3b
commit dd7f144bb3
7 changed files with 62 additions and 20 deletions

View File

@ -197,6 +197,8 @@
0E9CD7872257462800D033B4 /* Providers.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0E9CD7862257462800D033B4 /* Providers.xcassets */; };
0E9CD789225746B300D033B4 /* Flags.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0E9CD788225746B300D033B4 /* Flags.xcassets */; };
0E9CDB6723604AD5006733B4 /* ServerNetworkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E9CDB6623604AD5006733B4 /* ServerNetworkViewController.swift */; };
0EA9F29C26F9027700E806E1 /* VPN+Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EA9F29B26F9027700E806E1 /* VPN+Shared.swift */; };
0EA9F29D26F9027800E806E1 /* VPN+Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EA9F29B26F9027700E806E1 /* VPN+Shared.swift */; };
0EAAD71920E6669A0088754A /* GroupConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EDE8DED20C93E4C004C739C /* GroupConstants.swift */; };
0EB1F41C26B456C7003916BF /* Infrastructure+CredentialsPurpose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EB1F41B26B456C7003916BF /* Infrastructure+CredentialsPurpose.swift */; };
0EB1F41D26B456C7003916BF /* Infrastructure+CredentialsPurpose.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EB1F41B26B456C7003916BF /* Infrastructure+CredentialsPurpose.swift */; };
@ -508,6 +510,7 @@
0E9CD7862257462800D033B4 /* Providers.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Providers.xcassets; sourceTree = "<group>"; };
0E9CD788225746B300D033B4 /* Flags.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Flags.xcassets; sourceTree = "<group>"; };
0E9CDB6623604AD5006733B4 /* ServerNetworkViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerNetworkViewController.swift; sourceTree = "<group>"; };
0EA9F29B26F9027700E806E1 /* VPN+Shared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "VPN+Shared.swift"; sourceTree = "<group>"; };
0EB1F41B26B456C7003916BF /* Infrastructure+CredentialsPurpose.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Infrastructure+CredentialsPurpose.swift"; sourceTree = "<group>"; };
0EB60FD92111136E00AD27F3 /* UITextView+Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextView+Search.swift"; sourceTree = "<group>"; };
0EB67D6A2184581E00BA6200 /* ImportedHostsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImportedHostsViewController.swift; sourceTree = "<group>"; };
@ -1080,6 +1083,7 @@
0E569F14259F2D3E0022DFB8 /* Issue.swift */,
0EE247F526C115890080A4CE /* SwiftGen+Strings.swift */,
0E4FD7ED20D539A0002221FF /* Utils.swift */,
0EA9F29B26F9027700E806E1 /* VPN+Shared.swift */,
);
path = Sources;
sourceTree = "<group>";
@ -1855,6 +1859,7 @@
0E569F15259F2D3E0022DFB8 /* Issue.swift in Sources */,
0E3152D3223FA05400F61841 /* EndpointDataSource.swift in Sources */,
0E569F2D259F2DB10022DFB8 /* InfrastructureFactory.swift in Sources */,
0EA9F29C26F9027700E806E1 /* VPN+Shared.swift in Sources */,
0E3152D4223FA05400F61841 /* Preferences.swift in Sources */,
0EFB901822764689006405E4 /* ProfileNetworkSettings.swift in Sources */,
0E3152C0223FA03D00F61841 /* Utils.swift in Sources */,
@ -1921,6 +1926,7 @@
buildActionMask = 2147483647;
files = (
0E5204D3259F675400CBAB56 /* ConnectionService+Migration.swift in Sources */,
0EA9F29D26F9027800E806E1 /* VPN+Shared.swift in Sources */,
0E5204C1259F675400CBAB56 /* Infrastructure+Metadata.swift in Sources */,
0E5204BC259F674400CBAB56 /* TrustedNetworksUI.swift in Sources */,
0E5204D9259F675400CBAB56 /* Preferences.swift in Sources */,

View File

@ -41,9 +41,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
override init() {
AppConstants.Log.configure()
InfrastructureFactory.shared.preload()
#if !targetEnvironment(simulator)
VPN.shared = OpenVPNProvider(bundleIdentifier: AppConstants.App.tunnelBundleId)
#endif
super.init()
}

View File

@ -47,7 +47,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
override init() {
AppConstants.Log.configure()
InfrastructureFactory.shared.preload()
VPN.shared = OpenVPNProvider(bundleIdentifier: AppConstants.App.tunnelBundleId)
super.init()
}

View File

@ -123,18 +123,18 @@ public class GracefulVPN {
}
public func requestBytesCount(completionHandler: @escaping ((UInt, UInt)?) -> Void) {
guard let vpn = vpn else {
guard let ipc = vpn as? VPNProviderIPC else {
completionHandler(nil)
return
}
vpn.requestBytesCount(completionHandler: completionHandler)
ipc.requestBytesCount(completionHandler: completionHandler)
}
public func requestServerConfiguration(completionHandler: @escaping (Any?) -> Void) {
guard let vpn = vpn, vpn.status == .connected else {
guard let ipc = vpn as? VPNProviderIPC, vpn?.status == .connected else {
completionHandler(nil)
return
}
vpn.requestServerConfiguration(completionHandler: completionHandler)
ipc.requestServerConfiguration(completionHandler: completionHandler)
}
}

View File

@ -0,0 +1,35 @@
//
// VPN+Shared.swift
// Passepartout
//
// Created by Davide De Rosa on 9/20/21.
// Copyright (c) 2021 Davide De Rosa. All rights reserved.
//
// https://github.com/passepartoutvpn
//
// This file is part of Passepartout.
//
// Passepartout is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Passepartout is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Passepartout. If not, see <http://www.gnu.org/licenses/>.
//
import Foundation
import TunnelKit
public extension VPN {
#if os(macOS) || !targetEnvironment(simulator)
static let shared = OpenVPNProvider(bundleIdentifier: AppConstants.App.tunnelBundleId)
#else
static let shared = MockVPNProvider()
#endif
}

View File

@ -7,8 +7,8 @@ $tunnelkit_name = 'TunnelKit'
$tunnelkit_specs = ['Protocols/OpenVPN', 'Extra/LZO']
def shared_pods
pod_version $tunnelkit_name, $tunnelkit_specs, '~> 3.4.0'
#pod_git $tunnelkit_name, $tunnelkit_specs, '65774c9'
#pod_version $tunnelkit_name, $tunnelkit_specs, '~> 3.4.0'
pod_git $tunnelkit_name, $tunnelkit_specs, '48c7e06'
#pod_path $tunnelkit_name, $tunnelkit_specs, '..'
pod 'SSZipArchive'
pod 'Kvitto'

View File

@ -24,15 +24,15 @@ PODS:
- OpenSSL-Apple (1.1.1k.11)
- SSZipArchive (2.4.2)
- SwiftyBeaver (1.9.5)
- TunnelKit/AppExtension (3.4.0):
- TunnelKit/AppExtension (3.5.0):
- SwiftyBeaver
- TunnelKit/Core
- TunnelKit/Core (3.4.0):
- TunnelKit/Core (3.5.0):
- SwiftyBeaver
- TunnelKit/Extra/LZO (3.4.0)
- TunnelKit/Manager (3.4.0):
- TunnelKit/Extra/LZO (3.5.0)
- TunnelKit/Manager (3.5.0):
- SwiftyBeaver
- TunnelKit/Protocols/OpenVPN (3.4.0):
- TunnelKit/Protocols/OpenVPN (3.5.0):
- OpenSSL-Apple (~> 1.1.1k.11)
- TunnelKit/AppExtension
- TunnelKit/Core
@ -52,8 +52,8 @@ DEPENDENCIES:
- Kvitto
- MBProgressHUD
- SSZipArchive
- TunnelKit/Extra/LZO (~> 3.4.0)
- TunnelKit/Protocols/OpenVPN (~> 3.4.0)
- TunnelKit/Extra/LZO (from `https://github.com/passepartoutvpn/tunnelkit`, commit `48c7e06`)
- TunnelKit/Protocols/OpenVPN (from `https://github.com/passepartoutvpn/tunnelkit`, commit `48c7e06`)
SPEC REPOS:
https://github.com/cocoapods/specs.git:
@ -63,17 +63,22 @@ SPEC REPOS:
- OpenSSL-Apple
- SSZipArchive
- SwiftyBeaver
- TunnelKit
EXTERNAL SOURCES:
Convenience:
:commit: 5ed1fe0
:git: https://github.com/keeshux/convenience
TunnelKit:
:commit: 48c7e06
:git: https://github.com/passepartoutvpn/tunnelkit
CHECKOUT OPTIONS:
Convenience:
:commit: 5ed1fe0
:git: https://github.com/keeshux/convenience
TunnelKit:
:commit: 48c7e06
:git: https://github.com/passepartoutvpn/tunnelkit
SPEC CHECKSUMS:
Convenience: c805c2aff569ff735c5d69c2c2b7a9bd110fa507
@ -83,8 +88,8 @@ SPEC CHECKSUMS:
OpenSSL-Apple: 3104e6d32de21815b68aeba31edaa6a78d90e7e0
SSZipArchive: e7b4f3d9e780c2acc1764cd88fbf2de28f26e5b2
SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82
TunnelKit: 93631182ccc2b19f19093649abeaffaff89e370d
TunnelKit: 25bb92319888bd7ca9b8a2fb1721e2a7442a3f6c
PODFILE CHECKSUM: 72464a4781505424ce1f94b497f3f1111e6c9858
PODFILE CHECKSUM: c403ea63bbad907c5fd40ed4bce86987f9ba90ad
COCOAPODS: 1.10.2