Refactor stale library entities
- Move VPNConfiguration* to VPN implementation - Drop old model protocols
This commit is contained in:
parent
2e10aab039
commit
e17224e61e
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import TunnelKitCore
|
import TunnelKitCore
|
||||||
import NetworkExtension
|
|
||||||
|
|
||||||
public enum Network {
|
public enum Network {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
//
|
|
||||||
// VPNConfiguration.swift
|
|
||||||
// Passepartout
|
|
||||||
//
|
|
||||||
// Created by Davide De Rosa on 3/7/22.
|
|
||||||
// Copyright (c) 2022 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 TunnelKitManager
|
|
||||||
import NetworkExtension
|
|
||||||
|
|
||||||
public typealias VPNConfiguration = (neConfiguration: NetworkExtensionConfiguration, neExtra: NetworkExtensionExtra?)
|
|
|
@ -1,41 +0,0 @@
|
||||||
//
|
|
||||||
// WrappedProfile.swift
|
|
||||||
// Passepartout
|
|
||||||
//
|
|
||||||
// Created by Davide De Rosa on 3/27/22.
|
|
||||||
// Copyright (c) 2022 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
|
|
||||||
|
|
||||||
public protocol WrappedProfile {
|
|
||||||
var isLoading: Bool { get }
|
|
||||||
|
|
||||||
var value: Profile { get }
|
|
||||||
}
|
|
||||||
|
|
||||||
extension WrappedProfile {
|
|
||||||
public var name: String {
|
|
||||||
guard !isLoading && !value.isPlaceholder else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return value.header.name
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
//
|
|
||||||
// WrappedVPNState.swift
|
|
||||||
// Passepartout
|
|
||||||
//
|
|
||||||
// Created by Davide De Rosa on 6/21/22.
|
|
||||||
// Copyright (c) 2022 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 TunnelKitCore
|
|
||||||
import TunnelKitManager
|
|
||||||
|
|
||||||
public protocol WrappedVPNState {
|
|
||||||
var isEnabled: Bool { get }
|
|
||||||
|
|
||||||
var vpnStatus: VPNStatus { get }
|
|
||||||
|
|
||||||
var lastError: Error? { get }
|
|
||||||
|
|
||||||
var dataCount: DataCount? { get }
|
|
||||||
}
|
|
|
@ -27,7 +27,7 @@ import Foundation
|
||||||
import PassepartoutCore
|
import PassepartoutCore
|
||||||
import PassepartoutUtils
|
import PassepartoutUtils
|
||||||
|
|
||||||
public class ObservableProfile: WrappedProfile, ValueHolder, ObservableObject {
|
public class ObservableProfile: ValueHolder, ObservableObject {
|
||||||
@Published public internal(set) var isLoading = false
|
@Published public internal(set) var isLoading = false
|
||||||
|
|
||||||
@Published public var value: Profile
|
@Published public var value: Profile
|
||||||
|
@ -36,3 +36,12 @@ public class ObservableProfile: WrappedProfile, ValueHolder, ObservableObject {
|
||||||
value = .placeholder
|
value = .placeholder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ObservableProfile {
|
||||||
|
public var name: String {
|
||||||
|
guard !isLoading && !value.isPlaceholder else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return value.header.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -26,10 +26,9 @@
|
||||||
import Foundation
|
import Foundation
|
||||||
import TunnelKitCore
|
import TunnelKitCore
|
||||||
import TunnelKitManager
|
import TunnelKitManager
|
||||||
import PassepartoutCore
|
|
||||||
import PassepartoutUtils
|
import PassepartoutUtils
|
||||||
|
|
||||||
public class ObservableVPNState: WrappedVPNState, ObservableObject {
|
public class ObservableVPNState: ObservableObject {
|
||||||
@Published public internal(set) var isEnabled = false {
|
@Published public internal(set) var isEnabled = false {
|
||||||
didSet {
|
didSet {
|
||||||
pp_log.debug("VPN enabled -> \(isEnabled)")
|
pp_log.debug("VPN enabled -> \(isEnabled)")
|
||||||
|
|
|
@ -28,6 +28,12 @@ import TunnelKitManager
|
||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
import PassepartoutCore
|
import PassepartoutCore
|
||||||
|
|
||||||
|
public typealias VPNConfiguration = (neConfiguration: NetworkExtensionConfiguration, neExtra: NetworkExtensionExtra)
|
||||||
|
|
||||||
|
protocol VPNConfigurationProviding {
|
||||||
|
func vpnConfiguration(_ parameters: VPNConfigurationParameters) throws -> VPNConfiguration
|
||||||
|
}
|
||||||
|
|
||||||
struct VPNConfigurationParameters {
|
struct VPNConfigurationParameters {
|
||||||
let title: String
|
let title: String
|
||||||
|
|
||||||
|
@ -63,7 +69,3 @@ struct VPNConfigurationParameters {
|
||||||
onDemandRules = profile.onDemandRules(withCustomRules: withCustomRules)
|
onDemandRules = profile.onDemandRules(withCustomRules: withCustomRules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protocol VPNConfigurationProviding {
|
|
||||||
func vpnConfiguration(_ parameters: VPNConfigurationParameters) throws -> VPNConfiguration
|
|
||||||
}
|
|
|
@ -24,5 +24,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
import PassepartoutCore
|
||||||
|
|
||||||
public typealias VPNConfigurationError = (profile: Profile, error: Error)
|
public typealias VPNConfigurationError = (profile: Profile, error: Error)
|
Loading…
Reference in New Issue