Treat empty DNS servers as nil

Empty local DNS array was pretty much hiding server-pushed DNS.
This commit is contained in:
Davide De Rosa 2019-04-17 00:42:07 +02:00
parent 537b733130
commit 28fd80f4e0
2 changed files with 9 additions and 3 deletions

View File

@ -560,7 +560,10 @@ extension TunnelKitProvider: SessionProxyDelegate {
ipv6Settings?.excludedRoutes = []
}
let dnsServers = cfg.sessionConfiguration.dnsServers ?? reply.options.dnsServers
var dnsServers = cfg.sessionConfiguration.dnsServers
if dnsServers?.isEmpty ?? true {
dnsServers = reply.options.dnsServers
}
let searchDomain = cfg.sessionConfiguration.searchDomain ?? reply.options.searchDomain
let dnsSettings = NEDNSSettings(servers: dnsServers ?? [])
dnsSettings.domainName = searchDomain

View File

@ -199,7 +199,7 @@ public class ConfigurationParser {
var optGateway4Arguments: [String]?
var optRoutes4: [(String, String, String?)] = [] // address, netmask, gateway
var optRoutes6: [(String, UInt8, String?)] = [] // destination, prefix, gateway
var optDNSServers: [String] = []
var optDNSServers: [String]?
var optSearchDomain: String?
var optHTTPProxy: Proxy?
var optHTTPSProxy: Proxy?
@ -482,7 +482,10 @@ public class ConfigurationParser {
guard $0.count == 2 else {
return
}
optDNSServers.append($0[1])
if optDNSServers == nil {
optDNSServers = []
}
optDNSServers?.append($0[1])
}
Regex.domain.enumerateArguments(in: line) {
guard $0.count == 2 else {