From 9a6f3d638c7378e1d7510789fba8c5c0da0e475f Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 19 Mar 2019 23:08:38 +0100 Subject: [PATCH] Recognize "--compress lzo" option as legal --- TunnelKit/Sources/Core/ConfigurationParser.swift | 15 +++++++++++---- .../Sources/Core/SessionProxy+PushReply.swift | 14 ++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/TunnelKit/Sources/Core/ConfigurationParser.swift b/TunnelKit/Sources/Core/ConfigurationParser.swift index 0a3ef19..0790ca1 100644 --- a/TunnelKit/Sources/Core/ConfigurationParser.swift +++ b/TunnelKit/Sources/Core/ConfigurationParser.swift @@ -315,10 +315,17 @@ public class ConfigurationParser { isHandled = true compressionFraming = .compress - guard $0.isEmpty else { - compressionAlgorithm = .other - unsupportedError = .unsupportedConfiguration(option: line) - return + if !LZOIsSupported() { + guard $0.isEmpty else { + unsupportedError = .unsupportedConfiguration(option: line) + return + } + } else { + if let arg = $0.first { + compressionAlgorithm = (arg == "lzo") ? .LZO : .other + } else { + compressionAlgorithm = .disabled + } } } Regex.keyDirection.enumerateArguments(in: line) { diff --git a/TunnelKit/Sources/Core/SessionProxy+PushReply.swift b/TunnelKit/Sources/Core/SessionProxy+PushReply.swift index 8d4baa0..af2282d 100644 --- a/TunnelKit/Sources/Core/SessionProxy+PushReply.swift +++ b/TunnelKit/Sources/Core/SessionProxy+PushReply.swift @@ -395,18 +395,20 @@ extension SessionProxy { switch $0[0] { case "comp-lzo": compressionFraming = .compLZO - if !(($0.count == 2) && ($0[1] == "no")) { - compressionAlgorithm = .LZO - } else { + if ($0.count == 2) && ($0[1] == "no") { compressionAlgorithm = .disabled + } else { + compressionAlgorithm = .LZO } case "compress": compressionFraming = .compress - if $0.count > 1 { - compressionAlgorithm = .other - } else { + if $0.count == 1 { compressionAlgorithm = .disabled + } else if ($0.count == 2) && ($0[1] == "lzo") { + compressionAlgorithm = .LZO + } else { + compressionAlgorithm = .other } default: