Review requirements of DNS over TLS (DoT)

- Make DNS servers optional in TunnelKit

- Allow IP address as DoT server name
This commit is contained in:
Davide De Rosa 2022-04-25 22:36:05 +02:00
parent efb9760d6b
commit 5c0e053e7d
5 changed files with 18 additions and 3 deletions

View File

@ -51,7 +51,7 @@
"repositoryURL": "https://github.com/passepartoutvpn/tunnelkit",
"state": {
"branch": null,
"revision": "f0a5557cfb144f66d1be8baf3abeca6d480e44e1",
"revision": "e075ba6a76ccfa0cc667a58933fb124c95c1f33d",
"version": null
}
},

View File

@ -427,6 +427,13 @@ extension View {
.disableAutocorrection(true)
}
func themeDNSOverTLSServerName(_ string: String?) -> some View {
themeValidating(string, validator: Validators.dnsOverTLSServerName)
.keyboardType(.asciiCapable)
.autocapitalization(.none)
.disableAutocorrection(true)
}
func themeSSID(_ text: String?) -> some View {
themeValidating(text, validator: Validators.notEmpty)
.keyboardType(.asciiCapable)

View File

@ -77,4 +77,12 @@ struct Validators {
throw ValidationError.url
}
}
static func dnsOverTLSServerName(_ string: String) throws {
do {
try domainName(string)
} catch {
try ipAddress(string)
}
}
}

View File

@ -157,7 +157,7 @@ extension NetworkSettingsView {
private var dnsManualTLSRow: some View {
TextField(Unlocalized.Placeholders.dotServerName, text: $settings.dns.dnsTLSServerName ?? "")
.themeDomainName(settings.dns.dnsTLSServerName)
.themeDNSOverTLSServerName(settings.dns.dnsTLSServerName)
}
private var dnsManualServers: some View {

View File

@ -24,7 +24,7 @@ let package = Package(
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
// .package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", from: "4.1.0"),
.package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", .revision("f0a5557cfb144f66d1be8baf3abeca6d480e44e1")),
.package(name: "TunnelKit", url: "https://github.com/passepartoutvpn/tunnelkit", .revision("e075ba6a76ccfa0cc667a58933fb124c95c1f33d")),
// .package(name: "TunnelKit", path: "../../tunnelkit"),
.package(url: "https://github.com/zoul/generic-json-swift", from: "2.0.0"),
.package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver", from: "1.9.0")