Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
修复 v2ray/v2ray-core/issues/1909
实现原理
Go 的程序启动后,会读取
/etc/resolv.conf
内的 DNS,用于域名解析的net.DefaultResolver
变量会使用这些 DNS默认情况下所有域名解析相关的函数都会使用
net.DefaultResolver
,其他项目也会使用这个,比如已存在的 QUIC 包由于 Android 并不存在
/etc/resolv.conf
,Go 语言使用了它的默认值127.0.0.1:53
地址作为 DNS 服务器,但 Android 也同样不存在这个 DNS 服务器这时
net.DefaultResolver
内的 DNS 地址为127.0.0.1:53
所以在 Android 操作系统中运行二进制程序会出现域名解析的问题
由此,此 PR 为 Android 系统替换默认的
net.DefaultResolver
,为其设置 DNS8.8.8.8:53
编译时按照文档编译即可