【发布时间】:2021-12-22 21:28:44
【问题描述】:
假设我想先尝试 Cloudflare DoH,然后在失败的情况下回退到 Google 的 DoH,我该怎么做?
不过,使用单个提供程序非常简单。
val appCache = Cache(File("cacheDir", "okhttpcache"), 10 * 1024 * 1024)
val bootstrapClient = OkHttpClient.Builder().cache(appCache).build()
val dns = DnsOverHttps.Builder().client(bootstrapClient)
.url("https://dns.google/dns-query".toHttpUrl())
.bootstrapDnsHosts(InetAddress.getByName("8.8.4.4"), InetAddress.getByName("8.8.8.8"))
.build()
val client = bootstrapClient.newBuilder().dns(dns).build()
【问题讨论】: