Эх сурвалжийг харах

Add more DoH providers (#7256)

* Add more DoH providers

* Fix IPs

(cherry picked from commit 18ea6c4f655cfde314eb6b6d8061af313ba3f78b)
kasperskier 2 жил өмнө
parent
commit
49c7dd0cac

+ 52 - 0
app/src/main/java/eu/kanade/tachiyomi/network/DohProviders.kt

@@ -13,6 +13,10 @@ const val PREF_DOH_CLOUDFLARE = 1
 const val PREF_DOH_GOOGLE = 2
 const val PREF_DOH_ADGUARD = 3
 const val PREF_DOH_QUAD9 = 4
+const val PREF_DOH_ALIDNS = 5
+const val PREF_DOH_DNSPOD = 6
+const val PREF_DOH_360 = 7
+const val PREF_DOH_QUAD101 = 8
 
 fun OkHttpClient.Builder.dohCloudflare() = dns(
     DnsOverHttps.Builder().client(build())
@@ -68,3 +72,51 @@ fun OkHttpClient.Builder.dohQuad9() = dns(
         )
         .build(),
 )
+
+fun OkHttpClient.Builder.dohAliDNS() = dns(
+    DnsOverHttps.Builder().client(build())
+        .url("https://dns.alidns.com/dns-query".toHttpUrl())
+        .bootstrapDnsHosts(
+            InetAddress.getByName("223.5.5.5"),
+            InetAddress.getByName("223.6.6.6"),
+            InetAddress.getByName("2400:3200::1"),
+            InetAddress.getByName("2400:3200:baba::1"),
+        )
+        .build(),
+)
+
+fun OkHttpClient.Builder.dohDNSPod() = dns(
+    DnsOverHttps.Builder().client(build())
+        .url("https://doh.pub/dns-query".toHttpUrl())
+        .bootstrapDnsHosts(
+            InetAddress.getByName("1.12.12.12"),
+            InetAddress.getByName("120.53.53.53"),
+        )
+        .build(),
+)
+
+fun OkHttpClient.Builder.doh360() = dns(
+    DnsOverHttps.Builder().client(build())
+        .url("https://doh.360.cn/dns-query".toHttpUrl())
+        .bootstrapDnsHosts(
+            InetAddress.getByName("101.226.4.6"),
+            InetAddress.getByName("218.30.118.6"),
+            InetAddress.getByName("123.125.81.6"),
+            InetAddress.getByName("140.207.198.6"),
+            InetAddress.getByName("180.163.249.75"),
+            InetAddress.getByName("101.199.113.208"),
+            InetAddress.getByName("36.99.170.86"),
+        )
+        .build(),
+)
+
+fun OkHttpClient.Builder.dohQuad101() = dns(
+    DnsOverHttps.Builder().client(build())
+        .url("https://dns.twnic.tw/dns-query".toHttpUrl())
+        .bootstrapDnsHosts(
+            InetAddress.getByName("101.101.101.101"),
+            InetAddress.getByName("2001:de4::101"),
+            InetAddress.getByName("2001:de4::102"),
+        )
+        .build(),
+)

+ 4 - 0
app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt

@@ -43,6 +43,10 @@ class NetworkHelper(context: Context) {
                 PREF_DOH_GOOGLE -> builder.dohGoogle()
                 PREF_DOH_ADGUARD -> builder.dohAdGuard()
                 PREF_DOH_QUAD9 -> builder.dohQuad9()
+                PREF_DOH_ALIDNS -> builder.dohAliDNS()
+                PREF_DOH_DNSPOD -> builder.dohDNSPod()
+                PREF_DOH_360 -> builder.doh360()
+                PREF_DOH_QUAD101 -> builder.dohQuad101()
             }
 
             return builder

+ 12 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt

@@ -16,9 +16,13 @@ import eu.kanade.tachiyomi.data.library.LibraryUpdateService
 import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target
 import eu.kanade.tachiyomi.data.preference.PreferenceValues
 import eu.kanade.tachiyomi.network.NetworkHelper
+import eu.kanade.tachiyomi.network.PREF_DOH_360
 import eu.kanade.tachiyomi.network.PREF_DOH_ADGUARD
+import eu.kanade.tachiyomi.network.PREF_DOH_ALIDNS
 import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
+import eu.kanade.tachiyomi.network.PREF_DOH_DNSPOD
 import eu.kanade.tachiyomi.network.PREF_DOH_GOOGLE
+import eu.kanade.tachiyomi.network.PREF_DOH_QUAD101
 import eu.kanade.tachiyomi.network.PREF_DOH_QUAD9
 import eu.kanade.tachiyomi.ui.base.controller.openInBrowser
 import eu.kanade.tachiyomi.ui.base.controller.withFadeTransaction
@@ -182,6 +186,10 @@ class SettingsAdvancedController : SettingsController() {
                     "Google",
                     "AdGuard",
                     "Quad9",
+                    "AliDNS",
+                    "DNSPod",
+                    "360",
+                    "Quad 101",
                 )
                 entryValues = arrayOf(
                     "-1",
@@ -189,6 +197,10 @@ class SettingsAdvancedController : SettingsController() {
                     PREF_DOH_GOOGLE.toString(),
                     PREF_DOH_ADGUARD.toString(),
                     PREF_DOH_QUAD9.toString(),
+                    PREF_DOH_ALIDNS.toString(),
+                    PREF_DOH_DNSPOD.toString(),
+                    PREF_DOH_360.toString(),
+                    PREF_DOH_QUAD101.toString(),
                 )
                 defaultValue = "-1"
                 summary = "%s"