From ac0e7713d6479adac7c03ff861cf7dea6506d646 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Fri, 24 Aug 2018 15:00:10 +0200 Subject: [PATCH] Parse IPv6 DNS servers dhcp-option can be DN6 (older) or DNS (newer). --- TunnelKit/Sources/Core/SessionProxy+PushReply.swift | 2 +- TunnelKitTests/PushTests.swift | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/TunnelKit/Sources/Core/SessionProxy+PushReply.swift b/TunnelKit/Sources/Core/SessionProxy+PushReply.swift index dabb4df..f922e22 100644 --- a/TunnelKit/Sources/Core/SessionProxy+PushReply.swift +++ b/TunnelKit/Sources/Core/SessionProxy+PushReply.swift @@ -96,7 +96,7 @@ extension SessionProxy { private static let routeRegexp = try! NSRegularExpression(pattern: "route [\\d\\.]+( [\\d\\.]+){0,2}", options: []) - private static let dnsRegexp = try! NSRegularExpression(pattern: "dhcp-option DNS [\\d\\.]+", options: []) + private static let dnsRegexp = try! NSRegularExpression(pattern: "dhcp-option DNS6? [\\d\\.a-fA-F:]+", options: []) private static let authTokenRegexp = try! NSRegularExpression(pattern: "auth-token [a-zA-Z0-9/=+]+", options: []) diff --git a/TunnelKitTests/PushTests.swift b/TunnelKitTests/PushTests.swift index 0914b88..052e094 100644 --- a/TunnelKitTests/PushTests.swift +++ b/TunnelKitTests/PushTests.swift @@ -78,4 +78,15 @@ class PushTests: XCTestCase { XCTAssertEqual(route.mask, "255.255.255.0") XCTAssertEqual(route.gateway, "10.8.0.12") } + + func testIPv6() { + let msg = "PUSH_REPLY,dhcp-option DNS6 2001:4860:4860::8888,dhcp-option DNS6 2001:4860:4860::8844,tun-ipv6,route-gateway 10.8.0.1,topology subnet,ping 10,ping-restart 120,ifconfig-ipv6 fe80::601:30ff:feb7:ec01/64 fe80::601:30ff:feb7:dc02,ifconfig 10.8.0.2 255.255.255.0,peer-id 0" + let reply = try! SessionProxy.PushReply(message: msg)! + reply.debug() + +// XCTAssertEqual(reply.address, "10.5.10.6") +// XCTAssertEqual(reply.addressMask, "255.255.255.255") +// XCTAssertEqual(reply.gatewayAddress, "10.5.10.5") + XCTAssertEqual(reply.dnsServers, ["2001:4860:4860::8888", "2001:4860:4860::8844"]) + } }