Skip to content

Commit

Permalink
macOS: Fix some VPN debug menu commands (#2260)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/0/1206686508201525/f

## Description

While testing I noticed some useful functionality from our debug menu
(specifically rekeying and triggering the debug notification) was no
longer working.

This should not affect anything other than our debug commands. I'm
enabling them again because it's really useful to be able to force a
rekey form the app.
  • Loading branch information
diegoreymendez authored Mar 3, 2024
1 parent 29835ac commit 0dfdac7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,20 @@ final class NetworkProtectionTunnelController: TunnelController, TunnelSessionPr
}
}

// MARK: - Debug Command support

func relay(_ command: DebugCommand) async throws {
guard await isConnected,
let session = await session else {
return
}

let errorMessage: ExtensionMessageString? = try await session.sendProviderRequest(.debugCommand(command))
if let errorMessage {
throw TunnelFailureError(errorDescription: errorMessage.value)
}
}

// MARK: - Tunnel Configuration

/// Setups the tunnel manager if it's not set up already.
Expand Down
6 changes: 4 additions & 2 deletions DuckDuckGoVPN/TunnelControllerIPCService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import NetworkProtectionUI
/// Clients can edit those defaults and this class will observe the changes and relay them to the runnel.
///
final class TunnelControllerIPCService {
private let tunnelController: TunnelController
private let tunnelController: NetworkProtectionTunnelController
private let networkExtensionController: NetworkExtensionController
private let server: NetworkProtectionIPC.TunnelControllerIPCServer
private let statusReporter: NetworkProtectionStatusReporter
private var cancellables = Set<AnyCancellable>()
private let defaults: UserDefaults

init(tunnelController: TunnelController,
init(tunnelController: NetworkProtectionTunnelController,
networkExtensionController: NetworkExtensionController,
statusReporter: NetworkProtectionStatusReporter,
defaults: UserDefaults = .netP) {
Expand Down Expand Up @@ -112,6 +112,8 @@ extension TunnelControllerIPCService: IPCServerInterface {
}

func debugCommand(_ command: DebugCommand) async throws {
try await tunnelController.relay(command)

switch command {
case .removeSystemExtension:
#if NETP_SYSTEM_EXTENSION
Expand Down

0 comments on commit 0dfdac7

Please sign in to comment.