Add DoH/DoT options
Signed-off-by: Davide De Rosa <keeshux@gmail.com>
This commit is contained in:
parent
cbcbf4369e
commit
73d9152fa0
|
@ -11,6 +11,8 @@ public struct InterfaceConfiguration {
|
||||||
public var mtu: UInt16?
|
public var mtu: UInt16?
|
||||||
public var dns = [DNSServer]()
|
public var dns = [DNSServer]()
|
||||||
public var dnsSearch = [String]()
|
public var dnsSearch = [String]()
|
||||||
|
public var dnsHTTPSURL: URL?
|
||||||
|
public var dnsTLSServerName: String?
|
||||||
|
|
||||||
public init(privateKey: PrivateKey) {
|
public init(privateKey: PrivateKey) {
|
||||||
self.privateKey = privateKey
|
self.privateKey = privateKey
|
||||||
|
@ -27,6 +29,8 @@ extension InterfaceConfiguration: Equatable {
|
||||||
lhs.listenPort == rhs.listenPort &&
|
lhs.listenPort == rhs.listenPort &&
|
||||||
lhs.mtu == rhs.mtu &&
|
lhs.mtu == rhs.mtu &&
|
||||||
lhs.dns == rhs.dns &&
|
lhs.dns == rhs.dns &&
|
||||||
lhs.dnsSearch == rhs.dnsSearch
|
lhs.dnsSearch == rhs.dnsSearch &&
|
||||||
|
lhs.dnsHTTPSURL == rhs.dnsHTTPSURL &&
|
||||||
|
lhs.dnsTLSServerName == rhs.dnsTLSServerName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,11 +85,25 @@ class PacketTunnelSettingsGenerator {
|
||||||
|
|
||||||
if !tunnelConfiguration.interface.dnsSearch.isEmpty || !tunnelConfiguration.interface.dns.isEmpty {
|
if !tunnelConfiguration.interface.dnsSearch.isEmpty || !tunnelConfiguration.interface.dns.isEmpty {
|
||||||
let dnsServerStrings = tunnelConfiguration.interface.dns.map { $0.stringRepresentation }
|
let dnsServerStrings = tunnelConfiguration.interface.dns.map { $0.stringRepresentation }
|
||||||
let dnsSettings = NEDNSSettings(servers: dnsServerStrings)
|
|
||||||
|
let dnsSettings: NEDNSSettings
|
||||||
|
if let dnsHTTPSURL = tunnelConfiguration.interface.dnsHTTPSURL {
|
||||||
|
let dohSettings = NEDNSOverHTTPSSettings(servers: dnsServerStrings)
|
||||||
|
dohSettings.serverURL = dnsHTTPSURL
|
||||||
|
dnsSettings = dohSettings
|
||||||
|
} else if let dnsTLSServerName = tunnelConfiguration.interface.dnsTLSServerName {
|
||||||
|
let dotSettings = NEDNSOverTLSSettings(servers: dnsServerStrings)
|
||||||
|
dotSettings.serverName = dnsTLSServerName
|
||||||
|
dnsSettings = dotSettings
|
||||||
|
} else {
|
||||||
|
dnsSettings = NEDNSSettings(servers: dnsServerStrings)
|
||||||
|
}
|
||||||
|
|
||||||
dnsSettings.searchDomains = tunnelConfiguration.interface.dnsSearch
|
dnsSettings.searchDomains = tunnelConfiguration.interface.dnsSearch
|
||||||
if !tunnelConfiguration.interface.dns.isEmpty {
|
if !tunnelConfiguration.interface.dns.isEmpty {
|
||||||
dnsSettings.matchDomains = [""] // All DNS queries must first go through the tunnel's DNS
|
dnsSettings.matchDomains = [""] // All DNS queries must first go through the tunnel's DNS
|
||||||
}
|
}
|
||||||
|
|
||||||
networkSettings.dnsSettings = dnsSettings
|
networkSettings.dnsSettings = dnsSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue