From 6fd1f96e549aa28f0b8fd8142e442eaa1f61a1db Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sat, 1 Apr 2023 21:40:15 +0200 Subject: [PATCH] Use a distinct debug log per VPN protocol (#277) Log content from different tunnels was interleaved. Store debug logs in a protocol-specific folder. --- .../Extensions/OpenVPNSettings+VPNConfiguration.swift | 4 +++- .../Extensions/VPNProtocolType+Extensions.swift | 8 ++++++++ .../Extensions/WireGuardSettings+VPNConfiguration.swift | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/OpenVPNSettings+VPNConfiguration.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/OpenVPNSettings+VPNConfiguration.swift index d289d38c..786593c1 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/OpenVPNSettings+VPNConfiguration.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/OpenVPNSettings+VPNConfiguration.swift @@ -58,7 +58,9 @@ extension Profile.OpenVPNSettings: VPNConfigurationProviding { ) cfg.username = parameters.username cfg.shouldDebug = true - cfg.debugLogPath = parameters.preferences.tunnelLogPath + if let filename = parameters.preferences.tunnelLogPath { + cfg.debugLogPath = vpnPath(with: filename) + } cfg.debugLogFormat = parameters.preferences.tunnelLogFormat cfg.masksPrivateData = parameters.preferences.masksPrivateData diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/VPNProtocolType+Extensions.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/VPNProtocolType+Extensions.swift index c8dc0375..d8c1a5de 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/VPNProtocolType+Extensions.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/VPNProtocolType+Extensions.swift @@ -63,3 +63,11 @@ extension VPNProtocolType { true } } + +extension VPNProtocolProviding { + func vpnPath(with path: String) -> String { + var components = path.split(separator: "/").map(String.init) + components.insert(vpnProtocol.description, at: components.count - 1) + return components.joined(separator: "/") + } +} diff --git a/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/WireGuardSettings+VPNConfiguration.swift b/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/WireGuardSettings+VPNConfiguration.swift index 250a1120..0f544221 100644 --- a/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/WireGuardSettings+VPNConfiguration.swift +++ b/PassepartoutLibrary/Sources/PassepartoutVPN/Extensions/WireGuardSettings+VPNConfiguration.swift @@ -48,7 +48,9 @@ extension Profile.WireGuardSettings: VPNConfigurationProviding { configuration: customConfiguration ) cfg.shouldDebug = true - cfg.debugLogPath = parameters.preferences.tunnelLogPath + if let filename = parameters.preferences.tunnelLogPath { + cfg.debugLogPath = vpnPath(with: filename) + } cfg.debugLogFormat = parameters.preferences.tunnelLogFormat var extra = NetworkExtensionExtra()