Move PlaceholderConnectionProfile to separate file

This commit is contained in:
Davide De Rosa 2018-11-06 11:06:40 +01:00
parent 0c389d8d8e
commit 389746180b
3 changed files with 71 additions and 35 deletions

View File

@ -40,6 +40,7 @@
0E5E5DE521511C5F00E318A3 /* GracefulVPN.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E5E5DE421511C5F00E318A3 /* GracefulVPN.swift */; };
0E6BE13A20CFB76800A6DD36 /* ApplicationError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */; };
0E6BE13F20CFBAB300A6DD36 /* DebugLogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */; };
0E79D13F21919EC900BB5FB2 /* PlaceholderConnectionProfile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E79D13E21919EC900BB5FB2 /* PlaceholderConnectionProfile.swift */; };
0E89DFC5213DF7AE00741BA1 /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFC4213DF7AE00741BA1 /* Preferences.swift */; };
0E89DFC8213E8FC500741BA1 /* SessionProxy+Communication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFC7213E8FC500741BA1 /* SessionProxy+Communication.swift */; };
0E89DFCE213EEDFA00741BA1 /* WizardProviderViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */; };
@ -162,6 +163,7 @@
0E5E5DE421511C5F00E318A3 /* GracefulVPN.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GracefulVPN.swift; sourceTree = "<group>"; };
0E6BE13920CFB76800A6DD36 /* ApplicationError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationError.swift; sourceTree = "<group>"; };
0E6BE13E20CFBAB300A6DD36 /* DebugLogViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebugLogViewController.swift; sourceTree = "<group>"; };
0E79D13E21919EC900BB5FB2 /* PlaceholderConnectionProfile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaceholderConnectionProfile.swift; sourceTree = "<group>"; };
0E89DFC4213DF7AE00741BA1 /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
0E89DFC7213E8FC500741BA1 /* SessionProxy+Communication.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SessionProxy+Communication.swift"; sourceTree = "<group>"; };
0E89DFCD213EEDFA00741BA1 /* WizardProviderViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WizardProviderViewController.swift; sourceTree = "<group>"; };
@ -368,6 +370,7 @@
isa = PBXGroup;
children = (
0EBE3AA3213DC1B000BFA2F5 /* HostConnectionProfile.swift */,
0E79D13E21919EC900BB5FB2 /* PlaceholderConnectionProfile.swift */,
0EBE3AA4213DC1B000BFA2F5 /* ProviderConnectionProfile.swift */,
);
path = Profiles;
@ -866,6 +869,7 @@
0ED38AE721404F100004D387 /* EndpointDataSource.swift in Sources */,
0E8D97E221388B52006FB4A0 /* InfrastructurePreset.swift in Sources */,
0ED31C3720CF38D10027975F /* VPN.swift in Sources */,
0E79D13F21919EC900BB5FB2 /* PlaceholderConnectionProfile.swift in Sources */,
0ED31C2920CF2A340027975F /* AccountViewController.swift in Sources */,
0E5E5DE521511C5F00E318A3 /* GracefulVPN.swift in Sources */,
0E158ADA20E11B0B00C85A82 /* EndpointViewController.swift in Sources */,

View File

@ -538,38 +538,3 @@ class ConnectionService: Codable {
// defaults.removeObject(forKey: Keys.vpnLog)
// }
}
private class PlaceholderConnectionProfile: ConnectionProfile {
let context: Context
let id: String
var username: String? = nil
var requiresCredentials: Bool = false
func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration {
fatalError("Generating configuration from a PlaceholderConnectionProfile")
}
func with(newId: String) -> ConnectionProfile {
return PlaceholderConnectionProfile(ConnectionService.ProfileKey(context, newId))
}
var mainAddress: String = ""
var addresses: [String] = []
var protocols: [TunnelKitProvider.EndpointProtocol] = []
var canCustomizeEndpoint: Bool = false
var customAddress: String?
var customProtocol: TunnelKitProvider.EndpointProtocol?
init(_ key: ConnectionService.ProfileKey) {
self.context = key.context
self.id = key.id
}
}

View File

@ -0,0 +1,67 @@
//
// PlaceholderConnectionProfile.swift
// Passepartout
//
// Created by Davide De Rosa on 11/6/18.
// Copyright (c) 2018 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
class PlaceholderConnectionProfile: ConnectionProfile {
let context: Context
let id: String
var username: String? = nil
var requiresCredentials: Bool = false
func generate(from configuration: TunnelKitProvider.Configuration, preferences: Preferences) throws -> TunnelKitProvider.Configuration {
fatalError("Generating configuration from a PlaceholderConnectionProfile")
}
func with(newId: String) -> ConnectionProfile {
return PlaceholderConnectionProfile(context, newId)
}
var mainAddress: String = ""
var addresses: [String] = []
var protocols: [TunnelKitProvider.EndpointProtocol] = []
var canCustomizeEndpoint: Bool = false
var customAddress: String?
var customProtocol: TunnelKitProvider.EndpointProtocol?
init(_ context: Context, _ id: String) {
self.context = context
self.id = id
}
init(_ key: ProfileKey) {
context = key.context
id = key.id
}
}