Fix cipher regex in PUSH_REPLY

Breaks with NCP enabled when cipher is not last. Trailing comma
was erroneously included in parsed cipher name.

Fixes #11
This commit is contained in:
Davide De Rosa 2018-09-05 03:53:16 +02:00
parent d6ed402b19
commit 43a5972737
2 changed files with 10 additions and 2 deletions

View File

@ -190,7 +190,7 @@ extension SessionProxy {
private static let peerIdRegexp = try! NSRegularExpression(pattern: "peer-id [0-9]+", options: [])
private static let cipherRegexp = try! NSRegularExpression(pattern: "cipher [^\\s]+", options: [])
private static let cipherRegexp = try! NSRegularExpression(pattern: "cipher [^,\\s]+", options: [])
private let original: String

View File

@ -97,6 +97,14 @@ class PushTests: XCTestCase {
let reply = try! SessionProxy.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.cipher, .aes256cbc)
XCTAssertEqual(reply.cipher, .aes256gcm)
}
func testNCPTrailing() {
let msg = "PUSH_REPLY,dhcp-option DNS 8.8.8.8,dhcp-option DNS 4.4.4.4,comp-lzo no,route 10.8.0.1,topology net30,ping 10,ping-restart 120,ifconfig 10.8.0.18 10.8.0.17,peer-id 3,cipher AES-256-GCM,auth-token"
let reply = try! SessionProxy.PushReply(message: msg)!
reply.debug()
XCTAssertEqual(reply.cipher, .aes256gcm)
}
}