From 49c7dd0cacfe53bfd90ac3caa3e293821bfafe8b Mon Sep 17 00:00:00 2001 From: kasperskier <95685115+kasperskier@users.noreply.github.com> Date: Wed, 8 Jun 2022 05:58:58 +0800 Subject: [PATCH] Add more DoH providers (#7256) * Add more DoH providers * Fix IPs (cherry picked from commit 18ea6c4f655cfde314eb6b6d8061af313ba3f78b) --- .../kanade/tachiyomi/network/DohProviders.kt | 52 +++++++++++++++++++ .../kanade/tachiyomi/network/NetworkHelper.kt | 4 ++ .../ui/setting/SettingsAdvancedController.kt | 12 +++++ 3 files changed, 68 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/DohProviders.kt b/app/src/main/java/eu/kanade/tachiyomi/network/DohProviders.kt index 9a783495c5..f5ab389d63 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/DohProviders.kt +++ b/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(), +) diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt index c59056daf8..ea3106cb86 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt +++ b/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 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index 594ae3894a..666058b926 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/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"