Strip dependencies on TunnelKitCore
- TunnelKitManager - TunnelKitIKE - TunnelKitOpenVPNManager
This commit is contained in:
parent
f1f2dddbf2
commit
8e6624e113
|
@ -57,18 +57,16 @@ let package = Package(
|
|||
.target(
|
||||
name: "TunnelKitManager",
|
||||
dependencies: [
|
||||
"TunnelKitCore"
|
||||
"SwiftyBeaver"
|
||||
]),
|
||||
.target(
|
||||
name: "TunnelKitAppExtension",
|
||||
dependencies: [
|
||||
"TunnelKitCore",
|
||||
"SwiftyBeaver"
|
||||
"TunnelKitCore"
|
||||
]),
|
||||
.target(
|
||||
name: "TunnelKitIKE",
|
||||
dependencies: [
|
||||
"TunnelKitCore",
|
||||
"TunnelKitManager"
|
||||
]),
|
||||
.target(
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
@_exported import TunnelKitCore
|
||||
@_exported import TunnelKitManager
|
||||
|
|
|
@ -60,8 +60,6 @@ public class CoreConfiguration {
|
|||
public static var versionIdentifier: String?
|
||||
|
||||
public static let logsSensitiveData = false
|
||||
|
||||
public static var reconnectionDelay = 2.0
|
||||
}
|
||||
|
||||
extension CustomStringConvertible {
|
||||
|
|
|
@ -75,9 +75,8 @@ public struct EndpointProtocol: RawRepresentable, Equatable, CustomStringConvert
|
|||
extension EndpointProtocol: Codable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
let container = try decoder.singleValueContainer()
|
||||
guard let proto = try EndpointProtocol(rawValue: container.decode(String.self)) else {
|
||||
throw ConfigurationError.malformed(option: "remote/proto")
|
||||
}
|
||||
let rawValue = try container.decode(String.self)
|
||||
let proto = EndpointProtocol(rawValue: rawValue) ?? EndpointProtocol(.udp, 1198)
|
||||
self.init(proto.socketType, proto.port)
|
||||
}
|
||||
|
||||
|
|
|
@ -64,8 +64,8 @@ public class NativeProvider: VPNProvider {
|
|||
provider.disconnect(completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
public func reconnect(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) {
|
||||
provider.reconnect(configuration: configuration, completionHandler: completionHandler)
|
||||
public func reconnect(configuration: VPNConfiguration, delay: Double? = nil, completionHandler: ((Error?) -> Void)?) {
|
||||
provider.reconnect(configuration: configuration, delay: delay, completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
public func uninstall(completionHandler: (() -> Void)?) {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class MockVPNProvider: VPNProvider, VPNProviderIPC {
|
|||
completionHandler?(nil)
|
||||
}
|
||||
|
||||
public func reconnect(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) {
|
||||
public func reconnect(configuration: VPNConfiguration, delay: Double?, completionHandler: ((Error?) -> Void)?) {
|
||||
isEnabled = true
|
||||
status = .connected
|
||||
NotificationCenter.default.post(name: VPN.didChangeStatus, object: self)
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
import Foundation
|
||||
import NetworkExtension
|
||||
import SwiftyBeaver
|
||||
import TunnelKitCore
|
||||
|
||||
private let log = SwiftyBeaver.self
|
||||
|
||||
|
@ -147,10 +146,11 @@ public class NetworkExtensionVPNProvider: VPNProvider {
|
|||
manager.saveToPreferences(completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
public func reconnect(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) {
|
||||
public func reconnect(configuration: VPNConfiguration, delay: Double? = nil, completionHandler: ((Error?) -> Void)?) {
|
||||
guard let configuration = configuration as? NetworkExtensionVPNConfiguration else {
|
||||
fatalError("Not a NetworkExtensionVPNConfiguration")
|
||||
}
|
||||
let delay = delay ?? 2.0
|
||||
install(configuration: configuration) { error in
|
||||
guard error == nil else {
|
||||
completionHandler?(error)
|
||||
|
@ -161,7 +161,7 @@ public class NetworkExtensionVPNProvider: VPNProvider {
|
|||
}
|
||||
if self.status != .disconnected {
|
||||
self.manager?.connection.stopVPNTunnel()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + CoreConfiguration.reconnectionDelay, execute: connectBlock)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: connectBlock)
|
||||
} else {
|
||||
connectBlock()
|
||||
}
|
||||
|
|
|
@ -72,9 +72,10 @@ public protocol VPNProvider: AnyObject {
|
|||
Reconnects to the VPN.
|
||||
|
||||
- Parameter configuration: The `VPNConfiguration` to install.
|
||||
- Parameter delay: The reconnection delay in seconds.
|
||||
- Parameter completionHandler: The completion handler with an optional error.
|
||||
*/
|
||||
func reconnect(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?)
|
||||
func reconnect(configuration: VPNConfiguration, delay: Double?, completionHandler: ((Error?) -> Void)?)
|
||||
|
||||
/**
|
||||
Uninstalls the VPN profile.
|
||||
|
|
|
@ -37,10 +37,8 @@
|
|||
import Foundation
|
||||
import NetworkExtension
|
||||
import SwiftyBeaver
|
||||
import TunnelKitCore
|
||||
import TunnelKitOpenVPNCore
|
||||
import TunnelKitManager
|
||||
import CTunnelKitCore
|
||||
import TunnelKitOpenVPNCore
|
||||
import __TunnelKitUtils
|
||||
|
||||
private let log = SwiftyBeaver.self
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
import Foundation
|
||||
import NetworkExtension
|
||||
import TunnelKitOpenVPNCore
|
||||
import TunnelKitManager
|
||||
import TunnelKitOpenVPNCore
|
||||
|
||||
/// `VPNProvider` for OpenVPN protocol.
|
||||
public class OpenVPNProvider: VPNProvider, VPNProviderIPC {
|
||||
|
@ -71,8 +71,8 @@ public class OpenVPNProvider: VPNProvider, VPNProviderIPC {
|
|||
provider.disconnect(completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
public func reconnect(configuration: VPNConfiguration, completionHandler: ((Error?) -> Void)?) {
|
||||
provider.reconnect(configuration: configuration, completionHandler: completionHandler)
|
||||
public func reconnect(configuration: VPNConfiguration, delay: Double? = nil, completionHandler: ((Error?) -> Void)?) {
|
||||
provider.reconnect(configuration: configuration, delay: delay, completionHandler: completionHandler)
|
||||
}
|
||||
|
||||
public func uninstall(completionHandler: (() -> Void)?) {
|
||||
|
|
Loading…
Reference in New Issue