Parse dataCiphersFallback as last resort

Prioritize over deprecate cipher.
This commit is contained in:
Davide De Rosa 2021-01-08 19:46:16 +01:00
parent 7ea088e4a1
commit c15d6f521a
2 changed files with 12 additions and 2 deletions

View File

@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Handle `--data-ciphers` from OpenVPN 2.5 - Handle `--data-ciphers` and `data-ciphers-fallback` from OpenVPN 2.5
## 3.2.0 (2021-01-07) ## 3.2.0 (2021-01-07)

View File

@ -44,6 +44,8 @@ extension OpenVPN {
static let dataCiphers = NSRegularExpression("^(data-ciphers|ncp-ciphers) +[^,\\s]+(:[^,\\s]+)*") static let dataCiphers = NSRegularExpression("^(data-ciphers|ncp-ciphers) +[^,\\s]+(:[^,\\s]+)*")
static let dataCiphersFallback = NSRegularExpression("^data-ciphers-fallback +[^,\\s]+")
static let auth = NSRegularExpression("^auth +[\\w\\-]+") static let auth = NSRegularExpression("^auth +[\\w\\-]+")
static let compLZO = NSRegularExpression("^comp-lzo.*") static let compLZO = NSRegularExpression("^comp-lzo.*")
@ -202,6 +204,7 @@ extension OpenVPN {
var currentBlock: [String] = [] var currentBlock: [String] = []
var optDataCiphers: [Cipher]? var optDataCiphers: [Cipher]?
var optDataCiphersFallback: Cipher?
var optCipher: Cipher? var optCipher: Cipher?
var optDigest: Digest? var optDigest: Digest?
var optCompressionFraming: CompressionFraming? var optCompressionFraming: CompressionFraming?
@ -363,6 +366,13 @@ extension OpenVPN {
optDataCiphers?.append(cipher) optDataCiphers?.append(cipher)
} }
} }
Regex.dataCiphersFallback.enumerateArguments(in: line) {
isHandled = true
guard let rawValue = $0.first else {
return
}
optDataCiphersFallback = Cipher(rawValue: rawValue.uppercased())
}
Regex.auth.enumerateArguments(in: line) { Regex.auth.enumerateArguments(in: line) {
isHandled = true isHandled = true
guard let rawValue = $0.first else { guard let rawValue = $0.first else {
@ -635,7 +645,7 @@ extension OpenVPN {
// MARK: General // MARK: General
sessionBuilder.cipher = optCipher sessionBuilder.cipher = optDataCiphersFallback ?? optCipher
sessionBuilder.dataCiphers = optDataCiphers sessionBuilder.dataCiphers = optDataCiphers
sessionBuilder.digest = optDigest sessionBuilder.digest = optDigest
sessionBuilder.compressionFraming = optCompressionFraming sessionBuilder.compressionFraming = optCompressionFraming