From 80b4b7bee6ad14a4eb7c83f1358a3e15150a7a43 Mon Sep 17 00:00:00 2001 From: Ahmad Azwar Annas Date: Thu, 18 Aug 2022 12:59:40 +0000 Subject: [PATCH] Add Mullvad and Control D as DoH providers (#7785) --- .../kanade/tachiyomi/network/DohProviders.kt | 36 +++++++++++++++++++ .../kanade/tachiyomi/network/NetworkHelper.kt | 2 ++ .../ui/setting/SettingsAdvancedController.kt | 6 ++++ 3 files changed, 44 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 f5ab389d63..b73828d817 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/DohProviders.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/DohProviders.kt @@ -17,6 +17,8 @@ const val PREF_DOH_ALIDNS = 5 const val PREF_DOH_DNSPOD = 6 const val PREF_DOH_360 = 7 const val PREF_DOH_QUAD101 = 8 +const val PREF_DOH_MULLVAD = 9 +const val PREF_DOH_CONTROLD = 10 fun OkHttpClient.Builder.dohCloudflare() = dns( DnsOverHttps.Builder().client(build()) @@ -120,3 +122,37 @@ fun OkHttpClient.Builder.dohQuad101() = dns( ) .build(), ) + +/* + * Mullvad DoH + * without ad blocking option + * Source : https://mullvad.net/en/help/dns-over-https-and-dns-over-tls/ + */ +fun OkHttpClient.Builder.dohMullvad() = dns( + DnsOverHttps.Builder().client(build()) + .url("https://doh.mullvad.net/dns-query".toHttpUrl()) + .bootstrapDnsHosts( + InetAddress.getByName("194.242.2.2"), + InetAddress.getByName("193.19.108.2"), + InetAddress.getByName("2a07:e340::2"), + ) + .build(), +) + +/* + * Control D + * unfiltered option + * Source : https://controld.com/free-dns/? + */ + +fun OkHttpClient.Builder.dohControlD() = dns( + DnsOverHttps.Builder().client(build()) + .url("https://freedns.controld.com/p0".toHttpUrl()) + .bootstrapDnsHosts( + InetAddress.getByName("76.76.2.0"), + InetAddress.getByName("76.76.10.0"), + InetAddress.getByName("2606:1a40::"), + InetAddress.getByName("2606:1a40:1::"), + ) + .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 921d556e08..ef785c7015 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt @@ -47,6 +47,8 @@ class NetworkHelper(context: Context) { PREF_DOH_DNSPOD -> builder.dohDNSPod() PREF_DOH_360 -> builder.doh360() PREF_DOH_QUAD101 -> builder.dohQuad101() + PREF_DOH_MULLVAD -> builder.dohMullvad() + PREF_DOH_CONTROLD -> builder.dohControlD() } 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 b8cc5916d2..ab7f4b55b6 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 @@ -23,8 +23,10 @@ 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_MULLVAD import eu.kanade.tachiyomi.network.PREF_DOH_QUAD101 import eu.kanade.tachiyomi.network.PREF_DOH_QUAD9 +import eu.kanade.tachiyomi.network.PREF_DOH_CONTROLD import eu.kanade.tachiyomi.ui.base.controller.openInBrowser import eu.kanade.tachiyomi.ui.base.controller.pushController import eu.kanade.tachiyomi.ui.setting.database.ClearDatabaseController @@ -196,6 +198,8 @@ class SettingsAdvancedController( "DNSPod", "360", "Quad 101", + "Mullvad", + "Control D", ) entryValues = arrayOf( "-1", @@ -207,6 +211,8 @@ class SettingsAdvancedController( PREF_DOH_DNSPOD.toString(), PREF_DOH_360.toString(), PREF_DOH_QUAD101.toString(), + PREF_DOH_MULLVAD.toString(), + PREF_DOH_CONTROLD.toString(), ) defaultValue = "-1" summary = "%s"