Open
Conversation
echopi
reviewed
Apr 6, 2026
Contributor
echopi
left a comment
There was a problem hiding this comment.
感谢提交!功能设计合理,文档也很完整。Review 后发现几个需要关注的问题:
1. 不应提交 .vscode/settings.json
个人 IDE 配置不应进入仓库,建议删除并加入 .gitignore。
2. CACHE_TIME 从 60000 改为 5000 影响面过大
lib/rules/dns.js 中将默认 DNS 缓存从 60s 改为 5s,这是全局变更,影响所有 DNS 查询(不只是 dns:// 规则的),会显著增加 DNS 请求量。如果是为了 dns:// 的调试体验,建议只对指定 DNS 的查询使用短缓存,不要改全局默认值。
3. resolveWithSpecifiedDns 中 callback 存在被调用两次的 bug
timeout 触发后没有将 callback 置为 null,如果 DNS 请求稍后返回,handleCallback 中 callback 仍然非空会被再次调用。
对比现有的 lookupDNS 函数正确地在 timeout 后置 null 了:
// 现有代码
var timer = setTimeout(function () {
callback && callback(util.TIMEOUT_ERR);
callback = null; // <-- 防止二次调用
}, TIMEOUT);建议在 resolveWithSpecifiedDns 的 timeout 回调和 handleCallback 中都加上 callback = null。
4. dns.Resolver 实例未清理
resolveWithSpecifiedDns 中每次都 new dns.Resolver(),timeout 时没有调用 resolver.cancel() 清理,请求会一直悬挂。
5. 不相关的变更混入了 PR
index.html 的 v=2.10.1 → v=2.10.2 以及 js/index.js 的 minified 变更属于版本发布内容,混入功能 PR 会增加 diff 噪音和冲突概率,建议移除。
小建议:
rules-mode.js中isDns和isHost用了完全相同的type,可以合并为一个条件- 文档质量不错,中英双语齐全 👍
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.
增加dns协议,可以对不同的host使用不同的dns服务器。