diff --git a/app/build.gradle b/app/build.gradle
index c35775ea56..1b26840637 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -166,6 +166,7 @@ dependencies {
final okhttp_version = '4.7.2'
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
+ implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:$okhttp_version"
implementation 'com.squareup.okio:okio:2.6.0'
// TLS 1.3 support for Android < 10
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
index 851e170294..42df98f0cf 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt
@@ -155,6 +155,8 @@ object PreferenceKeys {
const val searchPinnedSourcesOnly = "search_pinned_sources_only"
+ const val enableDoh = "enable_doh"
+
fun trackUsername(syncId: Int) = "pref_mangasync_username_$syncId"
fun trackPassword(syncId: Int) = "pref_mangasync_password_$syncId"
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
index 8cb193959d..69ad48ceac 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt
@@ -234,4 +234,6 @@ class PreferencesHelper(val context: Context) {
fun migrateFlags() = flowPrefs.getInt("migrate_flags", Int.MAX_VALUE)
fun trustedSignatures() = flowPrefs.getStringSet("trusted_signatures", emptySet())
+
+ fun enableDoh() = prefs.getBoolean(Keys.enableDoh, false)
}
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 b61f8ccb15..0420038d55 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt
@@ -2,14 +2,21 @@ package eu.kanade.tachiyomi.network
import android.content.Context
import eu.kanade.tachiyomi.BuildConfig
+import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import java.io.File
+import java.net.InetAddress
import java.util.concurrent.TimeUnit
import okhttp3.Cache
+import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
+import okhttp3.dnsoverhttps.DnsOverHttps
import okhttp3.logging.HttpLoggingInterceptor
+import uy.kohesive.injekt.injectLazy
class NetworkHelper(context: Context) {
+ private val preferences: PreferencesHelper by injectLazy()
+
private val cacheDir = File(context.cacheDir, "network_cache")
private val cacheSize = 5L * 1024 * 1024 // 5 MiB
@@ -30,6 +37,27 @@ class NetworkHelper(context: Context) {
builder.addInterceptor(httpLoggingInterceptor)
}
+ if (preferences.enableDoh()) {
+ builder.dns(
+ DnsOverHttps.Builder().client(builder.build())
+ .url("https://cloudflare-dns.com/dns-query".toHttpUrl())
+ .bootstrapDnsHosts(
+ listOf(
+ InetAddress.getByName("162.159.36.1"),
+ InetAddress.getByName("162.159.46.1"),
+ InetAddress.getByName("1.1.1.1"),
+ InetAddress.getByName("1.0.0.1"),
+ InetAddress.getByName("162.159.132.53"),
+ InetAddress.getByName("2606:4700:4700::1111"),
+ InetAddress.getByName("2606:4700:4700::1001"),
+ InetAddress.getByName("2606:4700:4700::0064"),
+ InetAddress.getByName("2606:4700:4700::6400")
+ )
+ )
+ .build()
+ )
+ }
+
builder.build()
}
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 2e107e3951..823133b133 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
@@ -17,6 +17,7 @@ import eu.kanade.tachiyomi.data.cache.ChapterCache
import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target
+import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
import eu.kanade.tachiyomi.network.NetworkHelper
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.library.LibraryController
@@ -87,14 +88,6 @@ class SettingsAdvancedController : SettingsController() {
onClick { clearChapterCache() }
}
- preference {
- titleRes = R.string.pref_clear_cookies
-
- onClick {
- network.cookieManager.removeAll()
- activity?.toast(R.string.cookies_cleared)
- }
- }
preference {
titleRes = R.string.pref_clear_database
summaryRes = R.string.pref_clear_database_summary
@@ -107,6 +100,25 @@ class SettingsAdvancedController : SettingsController() {
}
}
+ preferenceCategory {
+ titleRes = R.string.label_data
+
+ preference {
+ titleRes = R.string.pref_clear_cookies
+
+ onClick {
+ network.cookieManager.removeAll()
+ activity?.toast(R.string.cookies_cleared)
+ }
+ }
+ switchPreference {
+ key = Keys.enableDoh
+ titleRes = R.string.pref_dns_over_https
+ summaryRes = R.string.pref_dns_over_https_summary
+ defaultValue = false
+ }
+ }
+
preferenceCategory {
titleRes = R.string.label_library
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f5db50c953..2c86687e20 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -361,13 +361,16 @@
Canceled restore
+ Network
+ Clear cookies
+ DNS over HTTPS (Cloudflare)
+ Requires app restart to take effect
+ Cookies cleared
Data
Clear chapter cache
Used: %1$s
Cache cleared. %1$d files have been deleted
An error occurred while clearing cache
- Clear cookies
- Cookies cleared
Dialog choices reset
Clear database
Delete history for manga that are not saved in your library