Use a distinct debug log per VPN protocol (#277)

Log content from different tunnels was interleaved.

Store debug logs in a protocol-specific folder.
This commit is contained in:
Davide De Rosa 2023-04-01 21:40:15 +02:00 committed by GitHub
parent 44e0ca9127
commit 6fd1f96e54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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: "/")
}
}

View File

@ -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()