Full OpenVPN XOR patch (#245)

This commit is contained in:
Davide De Rosa 2022-11-06 18:08:41 +01:00 committed by GitHub
parent c48e35887c
commit ba09dcffa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 77 additions and 33 deletions

View File

@ -10,6 +10,10 @@ on:
- '**/*.yml' - '**/*.yml'
- 'Passepartout/App/fastlane/**' - 'Passepartout/App/fastlane/**'
concurrency:
group: ${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs: jobs:
run_tests: run_tests:
name: Run tests name: Run tests

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- Ukranian translations (Dmitry Chirkin). [#243](https://github.com/passepartoutvpn/passepartout-apple/pull/243) - Ukranian translations (Dmitry Chirkin). [#243](https://github.com/passepartoutvpn/passepartout-apple/pull/243)
- OpenVPN: Full implementation of Tunnelblick XOR patch (tmthecoder). [#245](https://github.com/passepartoutvpn/passepartout-apple/pull/245), [tunnelkit#255][https://github.com/passepartoutvpn/tunnelkit/pull/255]
### Fixed ### Fixed

View File

@ -51,7 +51,7 @@
"repositoryURL": "https://github.com/passepartoutvpn/tunnelkit", "repositoryURL": "https://github.com/passepartoutvpn/tunnelkit",
"state": { "state": {
"branch": null, "branch": null,
"revision": "0d21731e12ac316274f8c200e39f4fb48097f3dd", "revision": "48af81e414e6f9d7ee43eb5c621a035ae939d520",
"version": null "version": null
} }
}, },

View File

@ -141,10 +141,13 @@ extension EndpointAdvancedView.OpenVPNView {
Text(L10n.Endpoint.Advanced.Openvpn.Items.Digest.caption) Text(L10n.Endpoint.Advanced.Openvpn.Items.Digest.caption)
.withTrailingText($0.localizedDescription) .withTrailingText($0.localizedDescription)
} }
settings.xor.map { // Text(Unlocalized.VPN.xor)
Text(Unlocalized.VPN.xor) // .withTrailingText(settings.xor.localizedDescription)
.withTrailingText($0.localizedDescriptionAsXOR) themeLongContentLink(
} Unlocalized.VPN.xor,
content: .constant(settings.xor.localizedLongDescription),
withPreview: settings.xor.localizedDescription
)
} header: { } header: {
Text(L10n.Endpoint.Advanced.Openvpn.Sections.Communication.header) Text(L10n.Endpoint.Advanced.Openvpn.Sections.Communication.header)
} }
@ -165,10 +168,13 @@ extension EndpointAdvancedView.OpenVPNView {
values: OpenVPN.Digest.available, values: OpenVPN.Digest.available,
description: \.localizedDescription description: \.localizedDescription
) )
builder.xorMask.map { // Text(Unlocalized.VPN.xor)
Text(Unlocalized.VPN.xor) // .withTrailingText(builder.xorMethod.localizedDescription)
.withTrailingText($0.localizedDescriptionAsXOR) themeLongContentLink(
} Unlocalized.VPN.xor,
content: .constant(builder.xorMethod.localizedLongDescription),
withPreview: builder.xorMethod.localizedDescription
)
} header: { } header: {
Text(L10n.Endpoint.Advanced.Openvpn.Sections.Communication.header) Text(L10n.Endpoint.Advanced.Openvpn.Sections.Communication.header)
} }
@ -309,11 +315,11 @@ extension EndpointAdvancedView.OpenVPNView {
} }
extension OpenVPN.Configuration { extension OpenVPN.Configuration {
var communicationSettings: (cipher: OpenVPN.Cipher?, digest: OpenVPN.Digest?, xor: UInt8?)? { var communicationSettings: (cipher: OpenVPN.Cipher?, digest: OpenVPN.Digest?, xor: OpenVPN.XORMethod?)? {
guard cipher != nil || digest != nil || xorMask != nil else { guard cipher != nil || digest != nil || xorMethod != nil else {
return nil return nil
} }
return (cipher, digest, xorMask) return (cipher, digest, xorMethod)
} }
var compressionSettings: (framing: OpenVPN.CompressionFraming?, algorithm: OpenVPN.CompressionAlgorithm?)? { var compressionSettings: (framing: OpenVPN.CompressionFraming?, algorithm: OpenVPN.CompressionAlgorithm?)? {

View File

@ -38,16 +38,6 @@ extension OpenVPN.Digest {
} }
} }
extension UInt8 {
var localizedDescriptionAsXOR: String {
let V = L10n.Global.Strings.self
guard self != 0 else {
return V.disabled
}
return String(format: "0x%02x", UInt8(self))
}
}
extension OpenVPN.CompressionFraming { extension OpenVPN.CompressionFraming {
var localizedDescription: String { var localizedDescription: String {
switch self { switch self {
@ -81,18 +71,51 @@ extension OpenVPN.CompressionAlgorithm {
extension Optional where Wrapped == OpenVPN.TLSWrap { extension Optional where Wrapped == OpenVPN.TLSWrap {
var localizedDescription: String { var localizedDescription: String {
let V = L10n.Endpoint.Advanced.Openvpn.Items.self guard let strategy = self?.strategy else {
if let strategy = self?.strategy {
switch strategy {
case .auth:
return V.TlsWrapping.Value.auth
case .crypt:
return V.TlsWrapping.Value.crypt
}
} else {
return L10n.Global.Strings.disabled return L10n.Global.Strings.disabled
} }
let V = L10n.Endpoint.Advanced.Openvpn.Items.self
switch strategy {
case .auth:
return V.TlsWrapping.Value.auth
case .crypt:
return V.TlsWrapping.Value.crypt
}
}
}
extension Optional where Wrapped == OpenVPN.XORMethod {
var localizedDescription: String {
guard let self = self else {
return L10n.Global.Strings.disabled
}
switch self {
case .xormask:
return Unlocalized.OpenVPN.XOR.xormask.rawValue
case .xorptrpos:
return Unlocalized.OpenVPN.XOR.xorptrpos.rawValue
case .reverse:
return Unlocalized.OpenVPN.XOR.reverse.rawValue
case .obfuscate:
return Unlocalized.OpenVPN.XOR.obfuscate.rawValue
}
}
var localizedLongDescription: String {
switch self {
case .xormask(let mask):
return "\(localizedDescription) \(mask.toHex())"
case .obfuscate(let mask):
return "\(localizedDescription) \(mask.toHex())"
default:
return localizedDescription
}
} }
} }

View File

@ -218,6 +218,16 @@ enum Unlocalized {
static let compress = "--compress" static let compress = "--compress"
static let lzo = "LZO" static let lzo = "LZO"
enum XOR: String {
case xormask
case xorptrpos
case reverse
case obfuscate
}
} }
enum Network { enum Network {

View File

@ -24,7 +24,7 @@ let package = Package(
// Dependencies declare other packages that this package depends on. // Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"), // .package(url: /* package url */, from: "1.0.0"),
// .package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", from: "5.0.0"), // .package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", from: "5.0.0"),
.package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", .revision("0d21731e12ac316274f8c200e39f4fb48097f3dd")), .package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", .revision("48af81e414e6f9d7ee43eb5c621a035ae939d520")),
// .package(name: "TunnelKit", path: "../../tunnelkit"), // .package(name: "TunnelKit", path: "../../tunnelkit"),
.package(url: "https://github.com/zoul/generic-json-swift", from: "2.0.0"), .package(url: "https://github.com/zoul/generic-json-swift", from: "2.0.0"),
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0") .package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0")