mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2025-01-11 00:39:06 +01:00
DoH Google + More updates to cloudflare / useragent from upstream
Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
parent
331d2fcd9e
commit
72f297f457
@ -130,9 +130,9 @@ dependencies {
|
|||||||
implementation("com.github.tfcporciuncula:flow-preferences:1.3.4")
|
implementation("com.github.tfcporciuncula:flow-preferences:1.3.4")
|
||||||
|
|
||||||
// Network client
|
// Network client
|
||||||
implementation("com.squareup.okhttp3:okhttp:${Versions.OKHTTP}")
|
implementation("com.squareup.okhttp3:okhttp:${Versions.okhttp}")
|
||||||
implementation("com.squareup.okhttp3:logging-interceptor:${Versions.OKHTTP}")
|
implementation("com.squareup.okhttp3:logging-interceptor:${Versions.okhttp}")
|
||||||
implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:${Versions.OKHTTP}")
|
implementation("com.squareup.okhttp3:okhttp-dnsoverhttps:${Versions.okhttp}")
|
||||||
implementation("com.squareup.okio:okio:2.10.0")
|
implementation("com.squareup.okio:okio:2.10.0")
|
||||||
|
|
||||||
// Chucker
|
// Chucker
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
package eu.kanade.tachiyomi
|
package eu.kanade.tachiyomi
|
||||||
|
|
||||||
|
import androidx.core.content.edit
|
||||||
|
import androidx.preference.PreferenceManager
|
||||||
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
import eu.kanade.tachiyomi.data.download.DownloadProvider
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
import eu.kanade.tachiyomi.data.updater.UpdaterJob
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||||
|
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
||||||
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
import eu.kanade.tachiyomi.ui.library.LibraryPresenter
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
@ -96,6 +100,17 @@ object Migrations {
|
|||||||
context.toast(R.string.myanimelist_relogin)
|
context.toast(R.string.myanimelist_relogin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (oldVersion < 71) {
|
||||||
|
// Migrate DNS over HTTPS setting
|
||||||
|
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
|
val wasDohEnabled = prefs.getBoolean("enable_doh", false)
|
||||||
|
if (wasDohEnabled) {
|
||||||
|
prefs.edit {
|
||||||
|
putInt(PreferenceKeys.dohProvider, PREF_DOH_CLOUDFLARE)
|
||||||
|
remove("enable_doh")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -191,7 +191,7 @@ object PreferenceKeys {
|
|||||||
|
|
||||||
const val createLegacyBackup = "create_legacy_backup"
|
const val createLegacyBackup = "create_legacy_backup"
|
||||||
|
|
||||||
const val enableDoh = "enable_doh"
|
const val dohProvider = "doh_provider"
|
||||||
|
|
||||||
const val showNsfwSource = "show_nsfw_source"
|
const val showNsfwSource = "show_nsfw_source"
|
||||||
const val showNsfwExtension = "show_nsfw_extension"
|
const val showNsfwExtension = "show_nsfw_extension"
|
||||||
|
@ -366,5 +366,5 @@ class PreferencesHelper(val context: Context) {
|
|||||||
fun labelNsfwExtension() = prefs.getBoolean(Keys.labelNsfwExtension, true)
|
fun labelNsfwExtension() = prefs.getBoolean(Keys.labelNsfwExtension, true)
|
||||||
|
|
||||||
fun createLegacyBackup() = flowPrefs.getBoolean(Keys.createLegacyBackup, true)
|
fun createLegacyBackup() = flowPrefs.getBoolean(Keys.createLegacyBackup, true)
|
||||||
fun enableDoh() = prefs.getBoolean(Keys.enableDoh, false)
|
fun dohProvider() = prefs.getInt(Keys.dohProvider, -1)
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,7 @@ class AndroidCookieJar : CookieJar {
|
|||||||
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
|
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
|
||||||
val urlString = url.toString()
|
val urlString = url.toString()
|
||||||
|
|
||||||
for (cookie in cookies) {
|
cookies.forEach { manager.setCookie(urlString, it.toString()) }
|
||||||
manager.setCookie(urlString, cookie.toString())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun loadForRequest(url: HttpUrl): List<Cookie> {
|
override fun loadForRequest(url: HttpUrl): List<Cookie> {
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
package eu.kanade.tachiyomi.network
|
||||||
|
|
||||||
|
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.dnsoverhttps.DnsOverHttps
|
||||||
|
import java.net.InetAddress
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Based on https://github.com/square/okhttp/blob/ef5d0c83f7bbd3a0c0534e7ca23cbc4ee7550f3b/okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DohProviders.java
|
||||||
|
*/
|
||||||
|
|
||||||
|
const val PREF_DOH_CLOUDFLARE = 1
|
||||||
|
const val PREF_DOH_GOOGLE = 2
|
||||||
|
|
||||||
|
fun OkHttpClient.Builder.dohCloudflare() = dns(
|
||||||
|
DnsOverHttps.Builder().client(build())
|
||||||
|
.url("https://cloudflare-dns.com/dns-query".toHttpUrl())
|
||||||
|
.bootstrapDnsHosts(
|
||||||
|
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()
|
||||||
|
)
|
||||||
|
|
||||||
|
fun OkHttpClient.Builder.dohGoogle() = dns(
|
||||||
|
DnsOverHttps.Builder().client(build())
|
||||||
|
.url("https://dns.google/dns-query".toHttpUrl())
|
||||||
|
.bootstrapDnsHosts(
|
||||||
|
InetAddress.getByName("8.8.4.4"),
|
||||||
|
InetAddress.getByName("8.8.8.8")
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
)
|
@ -34,7 +34,7 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
// * Preferences that a source may need.
|
// * Preferences that a source may need.
|
||||||
// */
|
// */
|
||||||
// val preferences: SharedPreferences by lazy {
|
// val preferences: SharedPreferences by lazy {
|
||||||
// Injekt.get<Application>().getSharedPreferences("source_$id", Context.MODE_PRIVATE)
|
// Injekt.get<Application>().getSharedPreferences(source.getPreferenceKey(), Context.MODE_PRIVATE)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,10 +34,10 @@ class ChapterLoader(
|
|||||||
return Observable.just(chapter)
|
return Observable.just(chapter)
|
||||||
.doOnNext { chapter.state = ReaderChapter.State.Loading }
|
.doOnNext { chapter.state = ReaderChapter.State.Loading }
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.flatMap {
|
.flatMap { readerChapter ->
|
||||||
Timber.d("Loading pages for ${chapter.chapter.name}")
|
Timber.d("Loading pages for ${chapter.chapter.name}")
|
||||||
|
|
||||||
val loader = getPageLoader(it)
|
val loader = getPageLoader(readerChapter)
|
||||||
chapter.pageLoader = loader
|
chapter.pageLoader = loader
|
||||||
|
|
||||||
loader.getPages().take(1).doOnNext { pages ->
|
loader.getPages().take(1).doOnNext { pages ->
|
||||||
@ -47,7 +47,7 @@ class ChapterLoader(
|
|||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnNext { pages ->
|
.doOnNext { pages ->
|
||||||
if (pages.isEmpty()) {
|
if (pages.isEmpty()) {
|
||||||
throw Exception("Page list is empty")
|
throw Exception(downloadManager.context.getString(R.string.no_pages_found))
|
||||||
}
|
}
|
||||||
|
|
||||||
chapter.state = ReaderChapter.State.Loaded(pages)
|
chapter.state = ReaderChapter.State.Loaded(pages)
|
||||||
|
@ -106,7 +106,8 @@ class HttpPageLoader(
|
|||||||
.getPageListFromCache(chapter.chapter)
|
.getPageListFromCache(chapter.chapter)
|
||||||
.onErrorResumeNext { source.fetchPageList(chapter.chapter) }
|
.onErrorResumeNext { source.fetchPageList(chapter.chapter) }
|
||||||
.map { pages ->
|
.map { pages ->
|
||||||
pages.mapIndexed { index, page -> // Don't trust sources and use our own indexing
|
pages.mapIndexed { index, page ->
|
||||||
|
// Don't trust sources and use our own indexing
|
||||||
ReaderPage(index, page.url, page.imageUrl)
|
ReaderPage(index, page.url, page.imageUrl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -231,28 +232,32 @@ class HttpPageLoader(
|
|||||||
private fun HttpSource.getCachedImage(page: ReaderPage): Observable<ReaderPage> {
|
private fun HttpSource.getCachedImage(page: ReaderPage): Observable<ReaderPage> {
|
||||||
val imageUrl = page.imageUrl ?: return Observable.just(page)
|
val imageUrl = page.imageUrl ?: return Observable.just(page)
|
||||||
|
|
||||||
return Observable.just(page).flatMap {
|
return Observable.just(page)
|
||||||
if (!chapterCache.isImageInCache(imageUrl)) {
|
.flatMap {
|
||||||
cacheImage(page)
|
if (!chapterCache.isImageInCache(imageUrl)) {
|
||||||
} else {
|
cacheImage(page)
|
||||||
Observable.just(page)
|
} else {
|
||||||
|
Observable.just(page)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.doOnNext {
|
.doOnNext {
|
||||||
val readerTheme = preferences.readerTheme().get()
|
val readerTheme = preferences.readerTheme().get()
|
||||||
if (readerTheme >= 2) {
|
if (readerTheme >= 2) {
|
||||||
val stream = chapterCache.getImageFile(imageUrl).inputStream()
|
val stream = chapterCache.getImageFile(imageUrl).inputStream()
|
||||||
val image = BitmapFactory.decodeStream(stream)
|
val image = BitmapFactory.decodeStream(stream)
|
||||||
page.bg = ImageUtil.autoSetBackground(
|
page.bg = ImageUtil.autoSetBackground(
|
||||||
image,
|
image,
|
||||||
readerTheme == 2,
|
readerTheme == 2,
|
||||||
preferences.context
|
preferences.context
|
||||||
)
|
)
|
||||||
page.bgType = PagerPageHolder.getBGType(readerTheme, preferences.context)
|
page.bgType = PagerPageHolder.getBGType(readerTheme, preferences.context)
|
||||||
stream.close()
|
stream.close()
|
||||||
|
}
|
||||||
|
page.stream = { chapterCache.getImageFile(imageUrl).inputStream() }
|
||||||
|
page.status = Page.READY
|
||||||
}
|
}
|
||||||
page.stream = { chapterCache.getImageFile(imageUrl).inputStream() }
|
.doOnError { page.status = Page.ERROR }
|
||||||
page.status = Page.READY
|
.onErrorReturn { page }
|
||||||
}.doOnError { page.status = Page.ERROR }.onErrorReturn { page }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,6 +23,8 @@ import eu.kanade.tachiyomi.data.library.LibraryUpdateService
|
|||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Target
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
|
import eu.kanade.tachiyomi.network.PREF_DOH_CLOUDFLARE
|
||||||
|
import eu.kanade.tachiyomi.network.PREF_DOH_GOOGLE
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import eu.kanade.tachiyomi.util.CrashLogUtil
|
import eu.kanade.tachiyomi.util.CrashLogUtil
|
||||||
@ -164,12 +166,17 @@ class SettingsAdvancedController : SettingsController() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switchPreference {
|
intListPreference(activity) {
|
||||||
key = "enable_doh"
|
key = PreferenceKeys.dohProvider
|
||||||
key = PreferenceKeys.enableDoh
|
titleRes = R.string.doh
|
||||||
titleRes = R.string.dns_over_https
|
entriesRes = arrayOf(R.string.disabled, R.string.cloudflare, R.string.google)
|
||||||
summaryRes = R.string.requires_app_restart
|
entryValues = listOf(-1, PREF_DOH_CLOUDFLARE, PREF_DOH_GOOGLE)
|
||||||
defaultValue = false
|
|
||||||
|
defaultValue = -1
|
||||||
|
onChange {
|
||||||
|
activity?.toast(R.string.requires_app_restart)
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
<string name="chapters_removed">Chapters removed.</string>
|
<string name="chapters_removed">Chapters removed.</string>
|
||||||
<string name="chapter_not_found">Chapter not found</string>
|
<string name="chapter_not_found">Chapter not found</string>
|
||||||
<string name="no_chapters_error">No chapters found</string>
|
<string name="no_chapters_error">No chapters found</string>
|
||||||
|
<string name="no_pages_found">No pages found</string>
|
||||||
<plurals name="remove_n_chapters">
|
<plurals name="remove_n_chapters">
|
||||||
<item quantity="one">Remove %1$d downloaded chapter?</item>
|
<item quantity="one">Remove %1$d downloaded chapter?</item>
|
||||||
<item quantity="other">Remove %1$d downloaded chapters?</item>
|
<item quantity="other">Remove %1$d downloaded chapters?</item>
|
||||||
@ -630,7 +631,10 @@
|
|||||||
<string name="saves_error_logs">Saves error logs to a file for sharing with the developers</string>
|
<string name="saves_error_logs">Saves error logs to a file for sharing with the developers</string>
|
||||||
<string name="crash_log_saved">Crash logs saved</string>
|
<string name="crash_log_saved">Crash logs saved</string>
|
||||||
<string name="network">Network</string>
|
<string name="network">Network</string>
|
||||||
<string name="dns_over_https">DNS over HTTPS (Cloudflare)</string>
|
<string name="doh">DNS over HTTPS</string>
|
||||||
|
<string name="disabled">Disabled</string>
|
||||||
|
<string name="cloudflare" translatable="false">Cloudflare</string>
|
||||||
|
<string name="google" translatable="false">Google</string>
|
||||||
<string name="requires_app_restart">Requires app restart to take effect</string>
|
<string name="requires_app_restart">Requires app restart to take effect</string>
|
||||||
<string name="used_">Used: %1$s</string>
|
<string name="used_">Used: %1$s</string>
|
||||||
<plurals name="cache_cleared">
|
<plurals name="cache_cleared">
|
||||||
|
@ -6,7 +6,6 @@ object Versions {
|
|||||||
const val FASTADAPTER = "5.0.0"
|
const val FASTADAPTER = "5.0.0"
|
||||||
const val HYPERION = "0.9.27"
|
const val HYPERION = "0.9.27"
|
||||||
const val NUCLEUS = "3.0.0"
|
const val NUCLEUS = "3.0.0"
|
||||||
const val OKHTTP = "4.8.1"
|
|
||||||
const val OSS_LICENSE = "17.0.0"
|
const val OSS_LICENSE = "17.0.0"
|
||||||
const val RETROFIT = "2.7.2"
|
const val RETROFIT = "2.7.2"
|
||||||
const val KOTLINSERIALIZATION = "1.0.1"
|
const val KOTLINSERIALIZATION = "1.0.1"
|
||||||
@ -65,7 +64,7 @@ object Versions {
|
|||||||
const val moshi = "1.9.3"
|
const val moshi = "1.9.3"
|
||||||
const val nucleus = "3.0.0"
|
const val nucleus = "3.0.0"
|
||||||
const val numberSlidingPicker = "1.0.3"
|
const val numberSlidingPicker = "1.0.3"
|
||||||
const val okhttp = "4.8.1"
|
const val okhttp = "5.0.0-alpha.2"
|
||||||
const val okio = "2.6.0"
|
const val okio = "2.6.0"
|
||||||
const val photoView = "2.3.0"
|
const val photoView = "2.3.0"
|
||||||
const val reactiveNetwork = "0.13.0"
|
const val reactiveNetwork = "0.13.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user