fix: 清理 chng_hosts 行末句点,避免 chinadns-ng 启动失败 - #33914
Conversation
There was a problem hiding this comment.
🟡 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
sedcleanup to also strip a trailing dot at end-of-line (s/\.$//) when generatingchng_hostsfor 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.
|
@hq450 麻烦有空审阅一下这个小修复。问题可稳定复现:DHCP hosts 条目以句点结尾时,chinadns-ng 会因 invalid domain 退出。当前补丁已统一 chng_hosts 路径并补充行末句点清洗,Shell 语法检查和 hosts 样例测试均已通过。 |
问题
ASUSWRT/Merlin 的 DHCP 静态主机条目可能在
/tmp/etc/hosts中生成以句点结尾的名称,例如:FancySS 将该文件复制为
/etc/chng_hosts后交给 chinadns-ng。当前清洗规则只处理句点后仍有空白字符的情况,遗漏位于行末的句点。chinadns-ng 随后报错并退出:启动脚本最终只能观察到 chinadns-ng 进程启动失败。
修复
在现有 hosts 清洗命令中增加
s/\.$//,同时覆盖:验证
sh -n fancyss/ss/ssconfig.sh通过所有地址、主机名和日志内容均使用通用占位示例。