Skip to content

Commit

Permalink
Push domain exclusions to internal release (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoreymendez authored Aug 7, 2024
1 parent 1d50e24 commit 1dabef4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public enum VPNCommand: Codable {
case removeSystemExtension
case removeVPNConfiguration
case sendTestNotification
case restartAdapter
case uninstallVPN
case disableConnectOnDemandAndShutDown
case quitAgent
Expand Down
23 changes: 23 additions & 0 deletions Sources/NetworkProtection/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
excludedRoutes: settings.excludedRanges,
dnsSettings: settings.dnsSettings,
regenerateKey: regenerateKey)

case .useConfiguration(let newTunnelConfiguration):
tunnelConfiguration = newTunnelConfiguration
}
Expand Down Expand Up @@ -1139,6 +1140,8 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
case .removeVPNConfiguration:
// Since the VPN configuration is being removed we may as well reset all state
handleResetAllState(completionHandler: completionHandler)
case .restartAdapter:
handleRestartAdapter(completionHandler: completionHandler)
case .uninstallVPN:
// Since the VPN configuration is being removed we may as well reset all state
handleResetAllState(completionHandler: completionHandler)
Expand Down Expand Up @@ -1170,6 +1173,26 @@ open class PacketTunnelProvider: NEPacketTunnelProvider {
}
}

private func handleRestartAdapter(completionHandler: ((Data?) -> Void)? = nil) {
Task {
do {
let tunnelConfiguration = try await generateTunnelConfiguration(serverSelectionMethod: currentServerSelectionMethod,
includedRoutes: includedRoutes ?? [],
excludedRoutes: settings.excludedRanges,
dnsSettings: settings.dnsSettings,
regenerateKey: false)

try await updateTunnelConfiguration(updateMethod: .useConfiguration(tunnelConfiguration),
reassert: false,
regenerateKey: false)

completionHandler?(nil)
} catch {
completionHandler?(nil)
}
}
}

private func handleGetLastErrorMessage(completionHandler: ((Data?) -> Void)? = nil) {
let response = controllerErrorStore.lastErrorMessage.map(ExtensionMessageString.init)
completionHandler?(response?.rawValue)
Expand Down
3 changes: 0 additions & 3 deletions Sources/NetworkProtection/WireGuardKit/WireGuardAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,6 @@ public class WireGuardAdapter {
}

if reassert {
// Tell the system that the tunnel is going to reconnect using new WireGuard
// configuration.
// This will broadcast the `NEVPNStatusDidChange` notification to the GUI process.
self.packetTunnelProvider?.reasserting = true
}

Expand Down

0 comments on commit 1dabef4

Please sign in to comment.