Add direct routes to DNS servers

If VPN is not default gateway.

Further fix of #94
This commit is contained in:
Davide De Rosa 2019-04-28 15:43:23 +02:00
parent 0b72a30cdd
commit f799f47c25
1 changed files with 12 additions and 1 deletions

View File

@ -618,6 +618,17 @@ extension TunnelKitProvider: SessionProxyDelegate {
} }
} }
// add direct routes to DNS servers
if !isGateway {
for server in dnsServers {
if server.contains(":") {
ipv6Settings?.includedRoutes?.insert(NEIPv6Route(destinationAddress: server, networkPrefixLength: 128), at: 0)
} else {
ipv4Settings?.includedRoutes?.insert(NEIPv4Route(destinationAddress: server, subnetMask: "255.255.255.255"), at: 0)
}
}
}
var proxySettings: NEProxySettings? var proxySettings: NEProxySettings?
if let httpsProxy = cfg.sessionConfiguration.httpsProxy ?? reply.options.httpsProxy { if let httpsProxy = cfg.sessionConfiguration.httpsProxy ?? reply.options.httpsProxy {
proxySettings = NEProxySettings() proxySettings = NEProxySettings()