-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Add fake dns #395
Add fake dns #395
Conversation
酷 不过你得先处理下 lint 的问题,更多稍后讨论 |
97bc667
to
f3ad63a
Compare
Fixed. Looks like the other failed test is not related. |
A new config object "fake" in DnsObject for toggling fake dns function Compare with sniffing, fake dns is not limited to http and tls traffic. It works across all inbounds. For example, when dns request come from one inbound, the local DNS server of v2ray will response with a unique fake IP for every unique domain name. Then later on v2ray received a request to one of the fake IP from any inbounds, it will override the request destination with the previously saved domain. By default, v2ray cache up to 65535 addresses. The old records will be discarded bases on LRU. The fake IP will be 240.x.x.x
感谢来自 @yuhan6665 的贡献! 经过V2Fly团队的内部讨论,这些代码可以合并入V2成为V2的新功能,但是在合并入V2之前需要完成以下修改。因为你所实现的功能是一个目前需求很高的功能,如果你不希望进行以下修改,这些修改可以由我完成后合并入V2。
请回复是否想自己完成上述修改。如果由我来实现的话,会把IP匹配这里做成一个sniffer,然后读取CIDR表示的FakeIP的IP段并通过BigInt和net.IP之间转换完成IP分配,之后将LRU的代码移动入common来保证其可复用。 |
@xiaokangwang 感谢大佬 review!
我当然愿意改不过我周一到周五可能比较忙,我争取抽时间改 :) |
我同意如果配置文件前后不匹配会出现无法将原请求映射回域名的情况,但是吧,这么做是为了保证没有启用Fake DNS的用户的代码不会因为Fake DNS部分的代码的错误而导致请求失败(即使现在没有错误未来也可能会有),而且并不是每个用户都会使用Fake DNS,要保证没有启用Fake DNS的用户完全不受到这些修改的影响(包括性能影响,未来可能会考虑增加更加更多的匹配机制)。 如果你同意的话这个修改就由我来完成,因为目前sniffer并不包含相应的接口来获取请求的IP,而配置文件解析的代码也没有检查配置的功能。改变接口的代码需要考虑比较多的事情,要和团队中其他的人沟通,并达成共识,而且这里的修改也基本都是维护者提出的要求,这几天我也稍微有点时间^_^。 |
@xiaokangwang 我改了两个小问题。 |
好的,感谢你的贡献。我这就开始整合和改进。 |
正在进行相应的整合,相关的代码正在 https://github.com/v2fly/v2ray-core/commits/dev-fakedns 分支被开发。 |
Close as work is moved to https://github.com/v2fly/v2ray-core/commits/dev-fakedns |
基于v2ray/v2ray-core#2237 并大幅精简的Fake DNS/IP
参考了一些v2ray/v2ray-core#2233 里面的讨论,与原pr区别如下:
提交原文:
A new config object "fake" in DnsObject for toggling fake dns function
Compare with sniffing, fake dns is not limited to http and tls traffic.
It works across all inbounds. For example, when dns request come
from one inbound, the local DNS server of v2ray will response with a
unique fake IP for every unique domain name. Then later on v2ray
received a request to one of the fake IP from any inbounds, it will
override the request destination with the previously saved domain.
By default, v2ray cache up to 65535 addresses. The old records will
be discarded bases on LRU. The fake IP will be 240.x.x.x