@@ -254,35 +254,14 @@ enum class Http {;
254254 val httpclientBuilder = OkHttpClient .Builder ()
255255 // Default is 10, extend it a bit for slow mobile connections.
256256 httpclientBuilder.connectTimeout(5 , TimeUnit .SECONDS )
257- httpclientBuilder.writeTimeout(10 , TimeUnit .SECONDS )
258- httpclientBuilder.readTimeout(15 , TimeUnit .SECONDS )
257+ httpclientBuilder.writeTimeout(5 , TimeUnit .SECONDS )
258+ httpclientBuilder.readTimeout(5 , TimeUnit .SECONDS )
259259 httpclientBuilder.proxy(Proxy .NO_PROXY ) // Do not use system proxy
260- var dns = Dns .SYSTEM
260+ // TODO: Make compatible w/ cronet
261+ // var dns = Dns.SYSTEM
261262 try {
262- val cloudflareBootstrap = arrayOf(
263- InetAddress .getByName(" 162.159.36.1" ),
264- InetAddress .getByName(" 162.159.46.1" ),
265- InetAddress .getByName(" 1.1.1.1" ),
266- InetAddress .getByName(" 1.0.0.1" ),
267- InetAddress .getByName(" 162.159.132.53" ),
268- InetAddress .getByName(" 2606:4700:4700::1111" ),
269- InetAddress .getByName(" 2606:4700:4700::1001" ),
270- InetAddress .getByName(" 2606:4700:4700::0064" ),
271- InetAddress .getByName(" 2606:4700:4700::6400" )
272- )
273- dns = Dns { s: String? ->
274- if (" cloudflare-dns.com" == s) {
275- return @Dns listOf<InetAddress >(* cloudflareBootstrap)
276- }
277- Dns .SYSTEM .lookup(s!! )
278- }
279- httpclientBuilder.dns(dns)
280263 val cookieJar = WebkitCookieManagerProxy ()
281264 httpclientBuilder.cookieJar(cookieJar)
282- dns = DnsOverHttps .Builder ().client(httpclientBuilder.build())
283- .url(" https://cloudflare-dns.com/dns-query" .toHttpUrl()).bootstrapDnsHosts(
284- * cloudflareBootstrap
285- ).build()
286265 } catch (e: UnknownHostException ) {
287266 Timber .e(e, " Failed to init DoH" )
288267 } catch (e: RuntimeException ) {
@@ -381,7 +360,7 @@ enum class Http {;
381360 // Gracefully fallback to okhttp
382361 }
383362 // Fallback DNS cache responses in case request fail but already succeeded once in the past
384- fallbackDNS = FallBackDNS (
363+ /* fallbackDNS = FallBackDNS(
385364 dns,
386365 "github.com",
387366 "api.github.com",
@@ -395,23 +374,12 @@ enum class Http {;
395374 "api.androidacy.com",
396375 "production-api.androidacy.com"
397376 )
398- httpclientBuilder.dns(Dns .SYSTEM )
377+ httpclientBuilder.dns(Dns.SYSTEM)*/
399378 httpClient = followRedirects(httpclientBuilder, true ).build()
400379 followRedirects(httpclientBuilder, false ).build()
401- httpclientBuilder.dns(fallbackDNS!! )
402380 httpClientDoH = followRedirects(httpclientBuilder, true ).build()
403381 followRedirects(httpclientBuilder, false ).build()
404- httpclientBuilder.cache(
405- Cache (
406- File (
407- mainApplication.cacheDir, " http_cache"
408- ), 16L * 1024L * 1024L
409- )
410- ) // 16Mib of cache
411- httpclientBuilder.dns(Dns .SYSTEM )
412382 httpClientWithCache = followRedirects(httpclientBuilder, true ).build()
413- httpclientBuilder.dns(fallbackDNS!! )
414- httpClientWithCacheDoH = followRedirects(httpclientBuilder, true ).build()
415383 if (MainApplication .forceDebugLogging) Timber .i(" Initialized Http successfully!" )
416384 doh = MainApplication .isDohEnabled
417385 }
0 commit comments