-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update bootstrap_dns_android #966
Changes from 24 commits
bbb1834
602e34d
de31ea3
fbdf783
c7158f4
35ffcd2
2bf158f
6dc353f
60a043e
90d5a29
1c12258
995f793
aba9fbd
88f0302
33b6d12
2555128
b98f06d
066a1eb
02c1267
528c268
4376c72
63a800f
06129f8
56614cc
f35b82c
00c452b
6033eaf
b424575
f7903f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package internet | ||
|
||
import ( | ||
"context" | ||
"net" | ||
) | ||
|
||
type DNSResolverFunc func() *net.Resolver | ||
|
||
var NewDNSResolver DNSResolverFunc = func() *net.Resolver { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个公开API的设计无法满足根据状态自动改变解析器,感觉未来要改。因此不应该成为一个公开的接口 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the public number may be a temporary way to provide a configurable dns address.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a best effort attempt to reduce the amount of API change. This is a API change for using V2Ray as library, the user of library can always patch V2Ray so there is no need to introduce a API that will change later. |
||
return &net.Resolver{ | ||
PreferGo: true, | ||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) { | ||
var dialer net.Dialer | ||
return dialer.DialContext(ctx, network, address) | ||
}, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// +build android | ||
|
||
package internet | ||
|
||
import ( | ||
"context" | ||
"net" | ||
) | ||
|
||
func init() { | ||
NewDNSResolver = func() *net.Resolver { | ||
return &net.Resolver{ | ||
PreferGo: true, | ||
Dial: func(ctx context.Context, network, _ string) (net.Conn, error) { | ||
const systemDNS = "8.8.8.8:53" | ||
This comment was marked as resolved.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you say a configurable dns address, not default "8.8.8.8:53"? this is a TODO item. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
这话我就不爱听了,做周边就可以投诉,那之前安卓跑二进制遇到 DNS 解析的问题时也没见得有人就出来改一下 v2ray/v2ray-core/issues/1909 再说这个更改虽然不优雅,但是
况且之前我的想法是从内置的 DNS 配置中取一个放到这里,要是没有配置再设置一个,但是那样很麻烦,而且硬编码也是和 @kslr 商量过的 如果说真的影响了安卓 App 的开发,获取到系统的 DNS 塞到内置的 DNS 里不就行了么,虽然还是用了 V2Ray 内置的 DNS,但是 DNS 地址还是用的系统的又有什么关系 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 之前修改已经解决了不能用的问题了。现在进一步的修改应该彻底的解决掉这个问题。如果仅仅影响Android的话倒是没有问题,但是实际上这个PR还产生了对其他平台的修改。我要求修改是基于这个PR产生了对于其他的平台的修改以及新建了一个不必要的公开API,而不是因为改了Android的部分。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果仅仅是更新了Android的部分的话当然是没有问题的。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个PR在我当时处理的时候还产生对其他平台的行为的修改。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
当时那个修改没有问题,毕竟解决了不能用的问题。现在想做的是看看能不能彻底的解决这个问题。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果不能长久的解决这个问题,就不应该去产生会让别人的配置炸掉的情况。我这里的这个高标准是因为这个PR在当时产生了会炸掉一些人设置的情况,所以要一次把问题解决。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CalmLong 给我的投诉是说现在的思路不够好,不是说你当时不应该改。当时的修改确实解决了一个问题,而且没有产生不好的影响,因此是很好的。我是希望能找到更好的改变的方法。 如果让你产生了误会, 我对其深表歉意。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
这个问题我会想办法解决的,非常抱歉。。。。 |
||
var dialer net.Dialer | ||
return dialer.DialContext(ctx, network, systemDNS) | ||
}, | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package internet | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
|
||
func TestDNSResolver(t *testing.T) { | ||
resolver := NewDNSResolver() | ||
if ips, err := resolver.LookupIP(context.Background(), "ip", "www.google.com"); err != nil { | ||
t.Errorf("failed to lookupIP, %v, %v", ips, err) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是一个针对 Adnroid 系统的修改,但是修改了在其他平台下的逻辑。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个设计没有考虑到是使用V2Ray自己的DNS系统进行解析的可能。