Cronet 支持DnsHttpsSvcb
Cronet 设置`UseDnsHttpsSvcb`等实验选项支持HTTPS 类型的dns请求,从dns HTTPS记录中就能获取到支持的alpn,用来确定升级http3。 https://github.com/chromium/chromium/commit/77379815db4354afa3a81c9dd26995c7edc76b16
This commit is contained in:
@@ -12,6 +12,7 @@ import org.chromium.net.CronetEngine.Builder.HTTP_CACHE_DISK
|
||||
import org.chromium.net.ExperimentalCronetEngine
|
||||
import org.chromium.net.UploadDataProviders
|
||||
import org.chromium.net.UrlRequest
|
||||
import org.json.JSONObject
|
||||
import splitties.init.appCtx
|
||||
|
||||
|
||||
@@ -29,6 +30,7 @@ val cronetEngine: ExperimentalCronetEngine? by lazy {
|
||||
enableHttp2(true) //设置支持http/2
|
||||
enablePublicKeyPinningBypassForLocalTrustAnchors(true)
|
||||
enableBrotli(true)//Brotli压缩
|
||||
setExperimentalOptions(options)
|
||||
}
|
||||
try {
|
||||
val engine = builder.build()
|
||||
@@ -40,6 +42,28 @@ val cronetEngine: ExperimentalCronetEngine? by lazy {
|
||||
}
|
||||
}
|
||||
|
||||
val options by lazy {
|
||||
val options = JSONObject()
|
||||
|
||||
//设置域名映射规则
|
||||
//MAP hostname ip,MAP hostname ip
|
||||
// val host = JSONObject()
|
||||
// host.put("host_resolver_rules","")
|
||||
// options.put("HostResolverRules", host)
|
||||
|
||||
//启用DnsHttpsSvcb更容易迁移到http3
|
||||
val dnsSvcb = JSONObject()
|
||||
dnsSvcb.put("enable", true)
|
||||
dnsSvcb.put("enable_insecure", true)
|
||||
dnsSvcb.put("use_alpn", true)
|
||||
options.put("UseDnsHttpsSvcb", dnsSvcb)
|
||||
|
||||
options.put("AsyncDNS", JSONObject("{'enable':true}"))
|
||||
|
||||
|
||||
options.toString()
|
||||
}
|
||||
|
||||
fun buildRequest(request: Request, callback: UrlRequest.Callback): UrlRequest? {
|
||||
val url = request.url.toString()
|
||||
val headers: Headers = request.headers
|
||||
|
||||
Reference in New Issue
Block a user