From 98b9d71eb340832c264dd87526867255fe1851da Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 22 Oct 2019 13:52:24 +0200 Subject: [PATCH] Assume VPN gateway when route gw is "vpn_gateway" --- CHANGELOG.md | 1 + .../Protocols/OpenVPN/ConfigurationParser.swift | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4e905c..c44d5f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Session negotiation succeeds too early (Robert Patchett). [#124](https://github.com/passepartoutvpn/tunnelkit/pull/124) +- Handle `vpn_gateway` literal in `--route`. ## 2.0.5 (2019-09-26) diff --git a/TunnelKit/Sources/Protocols/OpenVPN/ConfigurationParser.swift b/TunnelKit/Sources/Protocols/OpenVPN/ConfigurationParser.swift index c88cf5e..bf44310 100644 --- a/TunnelKit/Sources/Protocols/OpenVPN/ConfigurationParser.swift +++ b/TunnelKit/Sources/Protocols/OpenVPN/ConfigurationParser.swift @@ -490,7 +490,10 @@ extension OpenVPN { let address = routeEntryArguments[0] let mask = (routeEntryArguments.count > 1) ? routeEntryArguments[1] : "255.255.255.255" - let gateway = (routeEntryArguments.count > 2) ? routeEntryArguments[2] : nil // defaultGateway4 + var gateway = (routeEntryArguments.count > 2) ? routeEntryArguments[2] : nil // defaultGateway4 + if gateway == "vpn_gateway" { + gateway = nil + } optRoutes4.append((address, mask, gateway)) } Regex.route6.enumerateArguments(in: line) { @@ -505,7 +508,10 @@ extension OpenVPN { } let destination = destinationComponents[0] - let gateway = (routeEntryArguments.count > 1) ? routeEntryArguments[1] : nil // defaultGateway6 + var gateway = (routeEntryArguments.count > 1) ? routeEntryArguments[1] : nil // defaultGateway6 + if gateway == "vpn_gateway" { + gateway = nil + } optRoutes6.append((destination, prefix, gateway)) } Regex.gateway.enumerateArguments(in: line) {