set DefaultResolver for Android#572
Merged
kslr merged 10 commits intov2fly:masterfrom Jan 2, 2021
CalmLong:master
Merged
Conversation
Contributor
|
有两个做法:
|
Contributor
Author
|
Test 只能这样写了 (无奈 |
Contributor
|
Thanks for your work |
This was referenced Feb 22, 2021
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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编译时按照文档编译即可