Skip to content

fix: 清理 chng_hosts 行末句点,避免 chinadns-ng 启动失败 - #33914

Open
SakuraToErii wants to merge 2 commits into
hq450:3.0from
SakuraToErii:fix-chinadns-hosts-trailing-dot
Open

fix: 清理 chng_hosts 行末句点,避免 chinadns-ng 启动失败#33914
SakuraToErii wants to merge 2 commits into
hq450:3.0from
SakuraToErii:fix-chinadns-hosts-trailing-dot

Conversation

@SakuraToErii

Copy link
Copy Markdown

问题

ASUSWRT/Merlin 的 DHCP 静态主机条目可能在 /tmp/etc/hosts 中生成以句点结尾的名称,例如:

192.0.2.10 client-host.

FancySS 将该文件复制为 /etc/chng_hosts 后交给 chinadns-ng。当前清洗规则只处理句点后仍有空白字符的情况,遗漏位于行末的句点。chinadns-ng 随后报错并退出:

[local_rr.zig:110 add_ip] invalid domain: 'client-host.'
[opt.zig:552 opt_hosts] failed to load hosts: '/etc/chng_hosts'

启动脚本最终只能观察到 chinadns-ng 进程启动失败。

修复

在现有 hosts 清洗命令中增加 s/\.$//,同时覆盖:

  • 句点后有空白字符的主机名
  • 位于行末的主机名

验证

  • sh -n fancyss/ss/ssconfig.sh 通过
  • 测试包含行末句点、同一行多个带句点别名和正常条目的 hosts 文件,输出符合预期
  • 手动复现中,原始 hosts 条目稳定触发 chinadns-ng 退出;删除行末句点后,chinadns-ng 完成初始化并持续运行

所有地址、主机名和日志内容均使用通用占位示例。

Copilot AI lite review requested due to automatic review settings August 28, 2026 04:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The edited block still has an internal path inconsistency (/tmp/etc/chng_hosts vs /etc/chng_hosts) that can prevent the cleaned hosts file from being generated/loaded correctly.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the chinadns-ng startup path to better sanitize hostnames copied from ASUSWRT/Merlin-generated hosts entries, specifically removing a trailing . at end-of-line to prevent chinadns-ng from rejecting invalid domains.

Changes:

  • Extend the existing sed cleanup to also strip a trailing dot at end-of-line (s/\.$//) when generating chng_hosts for chinadns-ng.
File summaries
File Description
fancyss/ss/ssconfig.sh Adds an extra sed expression to remove end-of-line trailing dots in hosts entries before chinadns-ng loads them.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread fancyss/ss/ssconfig.sh Outdated
@SakuraToErii

Copy link
Copy Markdown
Author

@hq450 麻烦有空审阅一下这个小修复。问题可稳定复现:DHCP hosts 条目以句点结尾时,chinadns-ng 会因 invalid domain 退出。当前补丁已统一 chng_hosts 路径并补充行末句点清洗,Shell 语法检查和 hosts 样例测试均已通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants