Skip to content

Commit

Permalink
Set includeAllNetworks for best-effort kill switch (#300)
Browse files Browse the repository at this point in the history
* Update CHANGELOG

* Make kill switch an option
  • Loading branch information
keeshux authored Oct 30, 2022
1 parent a3b8543 commit 0d21731
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
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

0 comments on commit 0d21731

Please sign in to comment.