diff --git a/Sources/NetworkProtection/ExtensionMessage/ExtensionRequest.swift b/Sources/NetworkProtection/ExtensionMessage/ExtensionRequest.swift index e4f95b4b1..03f59244c 100644 --- a/Sources/NetworkProtection/ExtensionMessage/ExtensionRequest.swift +++ b/Sources/NetworkProtection/ExtensionMessage/ExtensionRequest.swift @@ -18,15 +18,16 @@ import Foundation -public enum DebugCommand: Codable { +public enum VPNCommand: Codable { case expireRegistrationKey case removeSystemExtension case removeVPNConfiguration case sendTestNotification + case uninstallVPN case disableConnectOnDemandAndShutDown } public enum ExtensionRequest: Codable { case changeTunnelSetting(_ change: VPNSettings.Change) - case debugCommand(_ command: DebugCommand) + case command(_ command: VPNCommand) } diff --git a/Sources/NetworkProtection/PacketTunnelProvider.swift b/Sources/NetworkProtection/PacketTunnelProvider.swift index 3c3c12ecc..533cdb2b9 100644 --- a/Sources/NetworkProtection/PacketTunnelProvider.swift +++ b/Sources/NetworkProtection/PacketTunnelProvider.swift @@ -948,8 +948,8 @@ open class PacketTunnelProvider: NEPacketTunnelProvider { case .changeTunnelSetting(let change): handleSettingChangeAppRequest(change, completionHandler: completionHandler) completionHandler?(nil) - case .debugCommand(let command): - handleDebugCommand(command, completionHandler: completionHandler) + case .command(let command): + handle(command, completionHandler: completionHandler) } } @@ -1012,7 +1012,7 @@ open class PacketTunnelProvider: NEPacketTunnelProvider { } } - private func handleDebugCommand(_ command: DebugCommand, completionHandler: ((Data?) -> Void)? = nil) { + private func handle(_ command: VPNCommand, completionHandler: ((Data?) -> Void)? = nil) { switch command { case .removeSystemExtension: // Since the system extension is being removed we may as well reset all state @@ -1030,6 +1030,9 @@ open class PacketTunnelProvider: NEPacketTunnelProvider { case .removeVPNConfiguration: // Since the VPN configuration is being removed we may as well reset all state handleResetAllState(completionHandler: completionHandler) + case .uninstallVPN: + // Since the VPN configuration is being removed we may as well reset all state + handleResetAllState(completionHandler: completionHandler) } } diff --git a/Sources/NetworkProtection/VPNConfiguration/VPNConfigurationManager.swift b/Sources/NetworkProtection/VPNConfiguration/VPNConfigurationManager.swift deleted file mode 100644 index 1e376fbb1..000000000 --- a/Sources/NetworkProtection/VPNConfiguration/VPNConfigurationManager.swift +++ /dev/null @@ -1,36 +0,0 @@ -// -// VPNConfigurationManager.swift -// -// Copyright © 2023 DuckDuckGo. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import Foundation -import NetworkExtension - -public final class VPNConfigurationManager { - - public init() {} - - public func removeVPNConfiguration() async { - let tunnels = try? await NETunnelProviderManager.loadAllFromPreferences() - - if let tunnels = tunnels { - for tunnel in tunnels { - tunnel.connection.stopVPNTunnel() - try? await tunnel.removeFromPreferences() - } - } - } -}