diff --git a/CHANGELOG.md b/CHANGELOG.md index 81aecf03..817017bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Handling of extra whitespaces in .ovpn (Mike Mayer). [#17](https://github.com/keeshux/passepartout-ios/issues/17) + ## 1.0 beta 1150 (2018-10-27) ### Added diff --git a/Passepartout/Sources/VPN/TunnelKitProvider+FileConfiguration.swift b/Passepartout/Sources/VPN/TunnelKitProvider+FileConfiguration.swift index b683eeb5..cf6a18d6 100644 --- a/Passepartout/Sources/VPN/TunnelKitProvider+FileConfiguration.swift +++ b/Passepartout/Sources/VPN/TunnelKitProvider+FileConfiguration.swift @@ -365,7 +365,7 @@ private extension NSRegularExpression { return } let match = (string as NSString).substring(with: range) - let tokens = match.components(separatedBy: " ") + let tokens = match.components(separatedBy: " ").filter { !$0.isEmpty } block(tokens) } } @@ -376,7 +376,7 @@ private extension NSRegularExpression { return } let match = (string as NSString).substring(with: range) - var tokens = match.components(separatedBy: " ") + var tokens = match.components(separatedBy: " ").filter { !$0.isEmpty } tokens.removeFirst() block(tokens) } diff --git a/PassepartoutTests-iOS/FileConfigurationTests.swift b/PassepartoutTests-iOS/FileConfigurationTests.swift index acd967dc..34caa2e5 100644 --- a/PassepartoutTests-iOS/FileConfigurationTests.swift +++ b/PassepartoutTests-iOS/FileConfigurationTests.swift @@ -39,9 +39,14 @@ class FileConfigurationTests: XCTestCase { } func testPIA() throws { - let cfg = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary")).configuration - XCTAssertEqual(cfg.sessionConfiguration.cipher, .aes128cbc) - XCTAssertEqual(cfg.sessionConfiguration.digest, .sha1) + let file = try TunnelKitProvider.Configuration.parsed(from: url(withName: "pia-hungary")) + XCTAssertEqual(file.hostname, "hungary.privateinternetaccess.com") + XCTAssertEqual(file.configuration.sessionConfiguration.cipher, .aes128cbc) + XCTAssertEqual(file.configuration.sessionConfiguration.digest, .sha1) + XCTAssertEqual(file.configuration.endpointProtocols, [ + TunnelKitProvider.EndpointProtocol(.udp, 1198), + TunnelKitProvider.EndpointProtocol(.tcp, 502) + ]) } func testStripped() throws { diff --git a/PassepartoutTests-iOS/pia-hungary.ovpn b/PassepartoutTests-iOS/pia-hungary.ovpn index bb6859ea..24e2a592 100644 --- a/PassepartoutTests-iOS/pia-hungary.ovpn +++ b/PassepartoutTests-iOS/pia-hungary.ovpn @@ -1,7 +1,7 @@ client dev tun -remote hungary.privateinternetaccess.com 1198 udp -remote hungary.privateinternetaccess.com 502 tcp +remote hungary.privateinternetaccess.com 1198 udp +remote hungary.privateinternetaccess.com 502 tcp resolv-retry infinite nobind persist-key @@ -44,8 +44,8 @@ YDQ8z9v+DMO6iwyIDRiU -----END CERTIFICATE----- -cipher aes-128-cbc -auth sha1 +cipher aes-128-cbc +auth sha1 tls-client remote-cert-tls server auth-user-pass