Missed the network updates oops

Co-Authored-By: arkon <4098258+arkon@users.noreply.github.com>
This commit is contained in:
Jays2Kings 2021-04-14 20:15:46 -04:00
parent 72f297f457
commit 5c741e2fc5

View File

@ -2,14 +2,13 @@ package eu.kanade.tachiyomi.network
import android.content.Context import android.content.Context
import com.chuckerteam.chucker.api.ChuckerInterceptor import com.chuckerteam.chucker.api.ChuckerInterceptor
import eu.kanade.tachiyomi.BuildConfig
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import okhttp3.Cache import okhttp3.Cache
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.dnsoverhttps.DnsOverHttps
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy
import java.io.File import java.io.File
import java.net.InetAddress import java.util.concurrent.TimeUnit
class NetworkHelper(context: Context) { class NetworkHelper(context: Context) {
@ -25,32 +24,24 @@ class NetworkHelper(context: Context) {
OkHttpClient.Builder() OkHttpClient.Builder()
.cookieJar(cookieManager) .cookieJar(cookieManager)
.cache(Cache(cacheDir, cacheSize)) .cache(Cache(cacheDir, cacheSize))
.addInterceptor(ChuckerInterceptor(context)) .connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.addInterceptor(UserAgentInterceptor())
.apply { .apply {
if (preferences.enableDoh()) { if (BuildConfig.DEBUG) {
dns( addInterceptor(ChuckerInterceptor(context))
DnsOverHttps.Builder().client(build()) }
.url("https://cloudflare-dns.com/dns-query".toHttpUrl())
.bootstrapDnsHosts( when (preferences.dohProvider()) {
listOf( PREF_DOH_CLOUDFLARE -> dohCloudflare()
InetAddress.getByName("162.159.36.1"), PREF_DOH_GOOGLE -> dohGoogle()
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()
)
} }
}.build() }.build()
} }
val cloudflareClient = client.newBuilder() val cloudflareClient by lazy {
.addInterceptor(UserAgentInterceptor()) client.newBuilder()
.addInterceptor(CloudflareInterceptor(context)) .addInterceptor(CloudflareInterceptor(context))
.build() .build()
}
} }