From 5c0e053e7d7adc00fdd33dbd848cadd4b39f5847 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 25 Apr 2022 22:36:05 +0200 Subject: [PATCH] Review requirements of DNS over TLS (DoT) - Make DNS servers optional in TunnelKit - Allow IP address as DoT server name --- .../xcshareddata/swiftpm/Package.resolved | 2 +- Passepartout/App/Constants/Theme.swift | 7 +++++++ Passepartout/App/Reusable/Validators.swift | 8 ++++++++ Passepartout/App/Views/NetworkSettingsView.swift | 2 +- PassepartoutCore/Package.swift | 2 +- 5 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6ebf4342..5b5f3f02 100644 --- a/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Passepartout.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -51,7 +51,7 @@ "repositoryURL": "https://github.com/passepartoutvpn/tunnelkit", "state": { "branch": null, - "revision": "f0a5557cfb144f66d1be8baf3abeca6d480e44e1", + "revision": "e075ba6a76ccfa0cc667a58933fb124c95c1f33d", "version": null } }, diff --git a/Passepartout/App/Constants/Theme.swift b/Passepartout/App/Constants/Theme.swift index c07e0dfc..174d3156 100644 --- a/Passepartout/App/Constants/Theme.swift +++ b/Passepartout/App/Constants/Theme.swift @@ -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) diff --git a/Passepartout/App/Reusable/Validators.swift b/Passepartout/App/Reusable/Validators.swift index 63d172a8..70bd7e59 100644 --- a/Passepartout/App/Reusable/Validators.swift +++ b/Passepartout/App/Reusable/Validators.swift @@ -77,4 +77,12 @@ struct Validators { throw ValidationError.url } } + + static func dnsOverTLSServerName(_ string: String) throws { + do { + try domainName(string) + } catch { + try ipAddress(string) + } + } } diff --git a/Passepartout/App/Views/NetworkSettingsView.swift b/Passepartout/App/Views/NetworkSettingsView.swift index a8814718..15f07991 100644 --- a/Passepartout/App/Views/NetworkSettingsView.swift +++ b/Passepartout/App/Views/NetworkSettingsView.swift @@ -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 { diff --git a/PassepartoutCore/Package.swift b/PassepartoutCore/Package.swift index dc265d72..2f5835b3 100644 --- a/PassepartoutCore/Package.swift +++ b/PassepartoutCore/Package.swift @@ -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")