Merge pull request #51 from decodism/main

Text entry and preset changes
This commit is contained in:
Kenta Kubo 2022-05-05 02:17:11 +09:00 committed by GitHub
commit 201d6a3535
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 116 additions and 21 deletions

View file

@ -44,8 +44,8 @@ enum Presets {
servers: [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::64",
"2606:4700:4700::6400",
"2606:4700:4700::1111",
"2606:4700:4700::1001",
],
serverName: "cloudflare-dns.com"
)
@ -58,41 +58,80 @@ enum Presets {
servers: [
"1.1.1.1",
"1.0.0.1",
"2606:4700:4700::64",
"2606:4700:4700::6400",
"2606:4700:4700::1111",
"2606:4700:4700::1001",
],
serverURL: URL(string: "https://cloudflare-dns.com/dns-query")
)
)
),
.init(
name: "Quad9",
name: "1.1.1.1 (Block Malware)",
configuration: .dnsOverTLS(
DoTConfiguration(
servers: [
"1.1.1.2",
"1.0.0.2",
"2606:4700:4700::1112",
"2606:4700:4700::1002",
],
serverName: "cloudflare-dns.com"
)
)
),
.init(
name: "1.1.1.1 (Block Malware)",
configuration: .dnsOverHTTPS(
DoHConfiguration(
servers: [
"1.1.1.2",
"1.0.0.2",
"2606:4700:4700::1112",
"2606:4700:4700::1002",
],
serverURL: URL(string: "https://security.cloudflare-dns.com/dns-query")
)
)
),
.init(
name: "Quad9 (Block Malware)",
configuration: .dnsOverTLS(
DoTConfiguration(
servers: [
"9.9.9.9",
"149.112.112.112",
"2620:fe::fe",
"2620:fe::fe:9",
"2620:fe::9",
],
serverName: "dns.quad9.net"
)
)
),
.init(
name: "Quad9",
name: "Quad9 (Block Malware)",
configuration: .dnsOverHTTPS(
DoHConfiguration(
servers: [
"9.9.9.9",
"149.112.112.112",
"2620:fe::fe",
"2620:fe::fe:9",
"2620:fe::9",
],
serverURL: URL(string: "https://dns.quad9.net/dns-query")
)
)
),
.init(
name: "LibreDNS",
configuration: .dnsOverTLS(
DoTConfiguration(
servers: [
"116.202.176.26",
],
serverName: "dot.libredns.gr"
)
)
),
.init(
name: "LibreDNS",
configuration: .dnsOverHTTPS(
@ -105,7 +144,7 @@ enum Presets {
)
),
.init(
name: "LibreDNS (No Ads)",
name: "LibreDNS (Block Ads / Trackers)",
configuration: .dnsOverHTTPS(
DoHConfiguration(
servers: [
@ -115,5 +154,61 @@ enum Presets {
)
)
),
.init(
name: "AdGuard DNS",
configuration: .dnsOverTLS(
DoTConfiguration(
servers: [
"94.140.14.140",
"94.140.14.141",
"2a10:50c0::1:ff",
"2a10:50c0::2:ff",
],
serverName: "dns-unfiltered.adguard.com"
)
)
),
.init(
name: "AdGuard DNS",
configuration: .dnsOverHTTPS(
DoHConfiguration(
servers: [
"94.140.14.140",
"94.140.14.141",
"2a10:50c0::1:ff",
"2a10:50c0::2:ff",
],
serverURL: URL(string: "https://dns-unfiltered.adguard.com/dns-query")
)
)
),
.init(
name: "AdGuard DNS (Block Ads / Trackers)",
configuration: .dnsOverTLS(
DoTConfiguration(
servers: [
"94.140.14.14",
"94.140.15.15",
"2a10:50c0::ad1:ff",
"2a10:50c0::ad2:ff",
],
serverName: "dns.adguard.com"
)
)
),
.init(
name: "AdGuard DNS (Block Ads / Trackers)",
configuration: .dnsOverHTTPS(
DoHConfiguration(
servers: [
"94.140.14.14",
"94.140.15.15",
"2a10:50c0::ad1:ff",
"2a10:50c0::ad2:ff",
],
serverURL: URL(string: "https://dns.adguard.com/dns-query")
)
)
),
]
}

View file

@ -46,10 +46,10 @@ extension DetailView: View {
"IP address",
text: .init(
get: { configuration.servers[i] },
set: { configuration.servers[i] = $0 }
set: { configuration.servers[i] = $0.trimmingCharacters(in: .whitespacesAndNewlines) }
),
onCommit: {
self.server.configuration = .dnsOverTLS(configuration)
onEditingChanged: {
if (!$0) { self.server.configuration = .dnsOverTLS(configuration) }
}
)
.textContentType(.URL)
@ -84,11 +84,11 @@ extension DetailView: View {
configuration.serverName ?? ""
},
set: {
configuration.serverName = $0
configuration.serverName = $0.trimmingCharacters(in: .whitespacesAndNewlines)
}
),
onCommit: {
self.server.configuration = .dnsOverTLS(configuration)
onEditingChanged: {
if (!$0) { self.server.configuration = .dnsOverTLS(configuration) }
}
)
.multilineTextAlignment(.trailing)
@ -111,10 +111,10 @@ extension DetailView: View {
"IP address",
text: .init(
get: { configuration.servers[i] },
set: { configuration.servers[i] = $0 }
set: { configuration.servers[i] = $0.trimmingCharacters(in: .whitespacesAndNewlines) }
),
onCommit: {
self.server.configuration = .dnsOverHTTPS(configuration)
onEditingChanged: {
if (!$0) { self.server.configuration = .dnsOverHTTPS(configuration) }
}
)
.textContentType(.URL)
@ -149,11 +149,11 @@ extension DetailView: View {
configuration.serverURL?.absoluteString ?? ""
},
set: {
configuration.serverURL = URL(string: $0)
configuration.serverURL = URL(string: $0.trimmingCharacters(in: .whitespacesAndNewlines))
}
),
onCommit: {
self.server.configuration = .dnsOverHTTPS(configuration)
onEditingChanged: {
if (!$0) { self.server.configuration = .dnsOverHTTPS(configuration) }
}
)
.multilineTextAlignment(.trailing)