Move kill switch to configuration extras

This commit is contained in:
Davide De Rosa 2022-11-10 07:11:10 +01:00
parent 48af81e414
commit 47281cafc9
3 changed files with 7 additions and 9 deletions

View File

@ -38,6 +38,9 @@ public struct NetworkExtensionExtra {
/// Disconnects on sleep if `true`.
public var disconnectsOnSleep = false
/// Enables best-effort kill switch.
public var killSwitch = false
public init() {
}
}

View File

@ -59,9 +59,6 @@ extension OpenVPN {
/// The client configuration.
public let configuration: OpenVPN.Configuration
/// Enables kill switch.
public var killSwitch: Bool?
/// The optional username.
public var username: String?
@ -116,8 +113,8 @@ extension OpenVPN.ProviderConfiguration: NetworkExtensionConfiguration {
}
protocolConfiguration.disconnectOnSleep = extra?.disconnectsOnSleep ?? false
protocolConfiguration.providerConfiguration = try asDictionary()
if #available(iOS 14, *), let killSwitch = killSwitch {
protocolConfiguration.includeAllNetworks = killSwitch
if #available(iOS 14, *) {
protocolConfiguration.includeAllNetworks = extra?.killSwitch ?? false
}
return protocolConfiguration
}

View File

@ -49,8 +49,6 @@ extension WireGuard {
public let configuration: WireGuard.Configuration
public var killSwitch: Bool?
public var shouldDebug = false
public var debugLogPath: String? = nil
@ -85,8 +83,8 @@ extension WireGuard.ProviderConfiguration: NetworkExtensionConfiguration {
protocolConfiguration.passwordReference = extra?.passwordReference
protocolConfiguration.disconnectOnSleep = extra?.disconnectsOnSleep ?? false
protocolConfiguration.providerConfiguration = try asDictionary()
if #available(iOS 14, *), let killSwitch = killSwitch {
protocolConfiguration.includeAllNetworks = killSwitch
if #available(iOS 14, *) {
protocolConfiguration.includeAllNetworks = extra?.killSwitch ?? false
}
return protocolConfiguration
}