Conversation
Contributor
Author
2026-07-08 最新上游覆盖复核与范围确认本轮重新按最新 执行计划与复核结果:
验证: bash -n luci-app-openclash/root/usr/share/openclash/*.sh
bash -n luci-app-openclash/root/etc/init.d/openclash tests/fw4_dns_hijack_guard_test.sh
bash tests/fw4_dns_hijack_guard_test.sh
git diff --check origin/dev...HEAD
rg -n '^(<<<<<<<|=======|>>>>>>>)' luci-app-openclash/root/etc/init.d/openclash tests/fw4_dns_hijack_guard_test.sh以上均通过。未做 live router 写入验证;本轮只做静态与聚焦脚本验证。 |
This was referenced Jul 8, 2026
Closed
Closed
Contributor
Author
|
这个拆分 PR 已被新的合并版 PR 取代:#5229 原因:#5223、#5226 都修改 fw4 DNS 劫持/redirect 相邻逻辑,并且按任意顺序合并都会在 已在合并版 PR 中验证:
|
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.
Dependency chain
推荐合并顺序:本 PR 建议在已合入的 #5209 之后评审。#5209 提供了按 chain/family 区分的
fw4_has_dns_hijack_rule,本 PR 只把这个能力用于仍未保护的nat_outputDNS 劫持调用点。问题现象
在 fw4 +
router_self_proxy=1场景下,OpenClash restore/start 路径可能重复插入本机nat_outputDNS 劫持规则;如果 IPv6dstnat规则存在但nat_output规则缺失,当前代码也不会补回 IPv6 本机 DNS 劫持。根因
#5209 已让 helper 能区分
dstnat/nat_output和 IPv4 / IPv6,但调用点仍存在两个问题:nat_output插入不检查nat_output ipv4是否已存在。nat_output插入被包在dstnat ipv6guard 内,dstnat已存在时会跳过整段,导致缺失的nat_output不能自愈。证据
enable_redirect_dns=1和enable_redirect_dns=2都会在router_self_proxy=1时插入nat_outputDNS 规则。! fw4_has_dns_hijack_rule dstnat ipv6成立时才进入nat_output插入。reload "restore"可不经过完整 firewall revert 直接重设部分规则,因此调用点需要自身幂等。tests/fw4_dns_hijack_guard_test.sh现有 helper 用例只能证明 helper 可区分 chain/family;本 PR 增加调用点检查,确保真实nat_outputDNS 插入前存在同 family guard。修复方案
nat_outputDNS 插入前增加! fw4_has_dns_hijack_rule nat_output ipv4。nat_outputDNS 插入从dstnat ipv6guard 内拆出,并单独使用! fw4_has_dns_hijack_rule nat_output ipv6。dstnat、openclash_dns_redirect、iptables/fw3 分支和 DNS redirect 语义。为什么没有扩大修复范围
没有在本 PR 中重构
enable_redirect_dns=2的openclash_dns_redirect链刷新,也没有修改 fw3/iptables 路径。redirect chain 的重复规则和 jump 幂等属于另一个行为边界,需要单独评估 flush/guard 策略,避免把 DNS 转发语义和本机代理 DNS 劫持混在一个补丁里。与已有开启态 PR 的关系
nat_output调用点。nat_output幂等。验证命令和结果
均已通过:
最后一条无命中。
剩余风险
未做 live router 验证。本 PR 不改变已有规则的端口或目标,如果用户在 restore 路径中同时切换 DNS redirect 模式/端口,仍依赖完整 firewall revert 或后续 redirect chain 幂等修复来刷新旧规则。