Merge branch 'multiple-search-domains'
This commit is contained in:
commit
0ab913fb24
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Allow keep-alive timeout to be configured by the server or client (Robert Patchett). [#122](https://github.com/passepartoutvpn/tunnelkit/pull/122)
|
||||
- Support for proxy autoconfiguration URL (ThinkChaos). [#125](https://github.com/passepartoutvpn/tunnelkit/pull/125)
|
||||
- Support multiple DNS search domains. [#127](https://github.com/passepartoutvpn/tunnelkit/issues/127)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ extension OpenVPNTunnelProvider {
|
|||
|
||||
static let dnsServers = "DNSServers"
|
||||
|
||||
static let searchDomain = "SearchDomain"
|
||||
static let searchDomains = "SearchDomains"
|
||||
|
||||
static let httpProxy = "HTTPProxy"
|
||||
|
||||
|
@ -519,8 +519,8 @@ private extension OpenVPN.Configuration {
|
|||
if let dnsServers = providerConfiguration[S.dnsServers] as? [String] {
|
||||
builder.dnsServers = dnsServers
|
||||
}
|
||||
if let searchDomain = providerConfiguration[S.searchDomain] as? String {
|
||||
builder.searchDomain = searchDomain
|
||||
if let searchDomains = providerConfiguration[S.searchDomains] as? [String] {
|
||||
builder.searchDomains = searchDomains
|
||||
}
|
||||
if let proxyString = providerConfiguration[S.httpProxy] as? String {
|
||||
guard let proxy = Proxy(rawValue: proxyString) else {
|
||||
|
@ -599,8 +599,8 @@ private extension OpenVPN.Configuration {
|
|||
if let dnsServers = dnsServers {
|
||||
dict[S.dnsServers] = dnsServers
|
||||
}
|
||||
if let searchDomain = searchDomain {
|
||||
dict[S.searchDomain] = searchDomain
|
||||
if let searchDomains = searchDomains {
|
||||
dict[S.searchDomains] = searchDomains
|
||||
}
|
||||
if let httpProxy = httpProxy {
|
||||
dict[S.httpProxy] = httpProxy.rawValue
|
||||
|
@ -680,8 +680,8 @@ private extension OpenVPN.Configuration {
|
|||
} else {
|
||||
log.info("\tDNS: not configured")
|
||||
}
|
||||
if let searchDomain = searchDomain, !searchDomain.isEmpty {
|
||||
log.info("\tSearch domain: \(searchDomain.maskedDescription)")
|
||||
if let searchDomains = searchDomains, !searchDomains.isEmpty {
|
||||
log.info("\tSearch domains: \(searchDomains.maskedDescription)")
|
||||
}
|
||||
if let httpProxy = httpProxy {
|
||||
log.info("\tHTTP proxy: \(httpProxy.maskedDescription)")
|
||||
|
|
|
@ -506,10 +506,10 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
|||
} else {
|
||||
log.info("\tDNS: not configured")
|
||||
}
|
||||
if let searchDomain = options.searchDomain, !searchDomain.isEmpty {
|
||||
log.info("\tDomain: \(searchDomain.maskedDescription)")
|
||||
if let searchDomains = options.searchDomains, !searchDomains.isEmpty {
|
||||
log.info("\tSearch domains: \(searchDomains.maskedDescription)")
|
||||
} else {
|
||||
log.info("\tDomain: not configured")
|
||||
log.info("\tSearch domains: not configured")
|
||||
}
|
||||
|
||||
if options.httpProxy != nil || options.httpsProxy != nil || options.proxyAutoConfigurationURL != nil {
|
||||
|
@ -652,9 +652,10 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
|||
if !isGateway {
|
||||
dnsSettings.matchDomains = [""]
|
||||
}
|
||||
if let searchDomain = cfg.sessionConfiguration.searchDomain ?? options.searchDomain {
|
||||
dnsSettings.domainName = searchDomain
|
||||
dnsSettings.searchDomains = [searchDomain]
|
||||
if let searchDomains = cfg.sessionConfiguration.searchDomains ?? options.searchDomains {
|
||||
log.info("DNS: Using search domains \(searchDomains.maskedDescription)")
|
||||
dnsSettings.domainName = searchDomains.first
|
||||
dnsSettings.searchDomains = searchDomains
|
||||
if !isGateway {
|
||||
dnsSettings.matchDomains = dnsSettings.searchDomains
|
||||
}
|
||||
|
|
|
@ -245,7 +245,19 @@ extension OpenVPN {
|
|||
public var dnsServers: [String]?
|
||||
|
||||
/// The search domain.
|
||||
public var searchDomain: String?
|
||||
@available(*, deprecated, message: "Use searchDomains instead")
|
||||
public var searchDomain: String? {
|
||||
didSet {
|
||||
guard let searchDomain = searchDomain else {
|
||||
searchDomains = nil
|
||||
return
|
||||
}
|
||||
searchDomains = [searchDomain]
|
||||
}
|
||||
}
|
||||
|
||||
/// The search domains. The first one is interpreted as the main domain name.
|
||||
public var searchDomains: [String]?
|
||||
|
||||
/// The Proxy Auto-Configuration (PAC) url.
|
||||
public var proxyAutoConfigurationURL: URL?
|
||||
|
@ -295,7 +307,7 @@ extension OpenVPN {
|
|||
ipv4: ipv4,
|
||||
ipv6: ipv6,
|
||||
dnsServers: dnsServers,
|
||||
searchDomain: searchDomain,
|
||||
searchDomains: searchDomains,
|
||||
httpProxy: httpProxy,
|
||||
httpsProxy: httpsProxy,
|
||||
proxyAutoConfigurationURL: proxyAutoConfigurationURL,
|
||||
|
@ -391,8 +403,8 @@ extension OpenVPN {
|
|||
/// - Seealso: `ConfigurationBuilder.dnsServers`
|
||||
public let dnsServers: [String]?
|
||||
|
||||
/// - Seealso: `ConfigurationBuilder.searchDomain`
|
||||
public let searchDomain: String?
|
||||
/// - Seealso: `ConfigurationBuilder.searchDomains`
|
||||
public let searchDomains: [String]?
|
||||
|
||||
/// - Seealso: `ConfigurationBuilder.httpProxy`
|
||||
public let httpProxy: Proxy?
|
||||
|
@ -461,7 +473,7 @@ extension OpenVPN.Configuration {
|
|||
builder.ipv4 = ipv4
|
||||
builder.ipv6 = ipv6
|
||||
builder.dnsServers = dnsServers
|
||||
builder.searchDomain = searchDomain
|
||||
builder.searchDomains = searchDomains
|
||||
builder.httpProxy = httpProxy
|
||||
builder.httpsProxy = httpsProxy
|
||||
builder.proxyAutoConfigurationURL = proxyAutoConfigurationURL
|
||||
|
|
|
@ -225,7 +225,7 @@ extension OpenVPN {
|
|||
var optRoutes4: [(String, String, String?)] = [] // address, netmask, gateway
|
||||
var optRoutes6: [(String, UInt8, String?)] = [] // destination, prefix, gateway
|
||||
var optDNSServers: [String]?
|
||||
var optSearchDomain: String?
|
||||
var optSearchDomains: [String]?
|
||||
var optHTTPProxy: Proxy?
|
||||
var optHTTPSProxy: Proxy?
|
||||
var optProxyAutoConfigurationURL: URL?
|
||||
|
@ -531,7 +531,10 @@ extension OpenVPN {
|
|||
guard $0.count == 2 else {
|
||||
return
|
||||
}
|
||||
optSearchDomain = $0[1]
|
||||
if optSearchDomains == nil {
|
||||
optSearchDomains = []
|
||||
}
|
||||
optSearchDomains?.append($0[1])
|
||||
}
|
||||
Regex.proxy.enumerateArguments(in: line) {
|
||||
if $0.count == 2 {
|
||||
|
@ -738,7 +741,7 @@ extension OpenVPN {
|
|||
}
|
||||
|
||||
sessionBuilder.dnsServers = optDNSServers
|
||||
sessionBuilder.searchDomain = optSearchDomain
|
||||
sessionBuilder.searchDomains = optSearchDomains
|
||||
sessionBuilder.httpProxy = optHTTPProxy
|
||||
sessionBuilder.httpsProxy = optHTTPSProxy
|
||||
sessionBuilder.proxyAutoConfigurationURL = optProxyAutoConfigurationURL
|
||||
|
|
Loading…
Reference in New Issue