Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Set includeAllNetworks for best-effort kill switch #300

Merged
merged 3 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- OpenVPN: Support for `--route-nopull`. [#280](https://github.com/passepartoutvpn/tunnelkit/pull/280)
- OpenVPN: Support for `--remote-random-hostname`. [#286](https://github.com/passepartoutvpn/tunnelkit/pull/286)
- Use .includeAllNetworks for best-effort kill switch. [#300](https://github.com/passepartoutvpn/tunnelkit/pull/300)

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ extension OpenVPN {
/// The client configuration.
public let configuration: OpenVPN.Configuration

/// Enables kill switch.
public var killSwitch: Bool?

/// The optional username.
public var username: String?

Expand Down Expand Up @@ -95,7 +98,7 @@ extension OpenVPN {

extension OpenVPN.ProviderConfiguration: NetworkExtensionConfiguration {

public func asTunnelProtocol(
public func asTunnelProtocol(
withBundleIdentifier tunnelBundleIdentifier: String,
extra: NetworkExtensionExtra?
) throws -> NETunnelProviderProtocol {
Expand All @@ -112,6 +115,9 @@ extension OpenVPN.ProviderConfiguration: NetworkExtensionConfiguration {
}
protocolConfiguration.disconnectOnSleep = extra?.disconnectsOnSleep ?? false
protocolConfiguration.providerConfiguration = try asDictionary()
if #available(iOS 14, *), let killSwitch = killSwitch {
protocolConfiguration.includeAllNetworks = killSwitch
}
return protocolConfiguration
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ extension WireGuard {

public let configuration: WireGuard.Configuration

public var killSwitch: Bool?

public var shouldDebug = false

public var debugLogPath: String? = nil
Expand All @@ -73,7 +75,7 @@ extension WireGuard {

extension WireGuard.ProviderConfiguration: NetworkExtensionConfiguration {

public func asTunnelProtocol(
public func asTunnelProtocol(
withBundleIdentifier tunnelBundleIdentifier: String,
extra: NetworkExtensionExtra?
) throws -> NETunnelProviderProtocol {
Expand All @@ -83,6 +85,9 @@ 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
}
return protocolConfiguration
}
}
Expand Down