Files
dns-server/.trae/documents/配置文件移除文件路径定义并固定文件位置.md
2026-01-14 23:08:46 +08:00

47 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
1. **修改配置结构体定义**
*`config/config.go`中的`DNSConfig`结构体移除`StatsFile`字段
*`ShieldConfig`结构体移除`LocalRulesFile``HostsFile``StatsFile``RemoteRulesCacheDir`字段
*`LogConfig`结构体移除`File`字段
2. **修改配置加载逻辑**
*`config/config.go``LoadConfig`函数中,移除对上述字段的默认值设置
3. **修改代码中使用配置的地方**
* `dns/server.go`:将`s.config.StatsFile`替换为硬编码的`"data/stats.json"`
* `shield/manager.go`:将`m.config.StatsFile`替换为硬编码的`"data/shield_stats.json"`
* 其他使用这些配置项的地方也需要相应修改
4. **修改默认配置生成**
*`main.go``createDefaultConfig`函数中,移除所有文件路径相关的配置项
5. **修改Web界面配置处理**
* 修改`static/js/config.js`,移除对这些文件路径配置项的处理
6. **更新配置文件**
* 修改`config.json`,移除所有文件路径相关的配置项
固定的文件位置:
* 日志文件:`logs/dns-server.log`
* DNS统计文件`data/stats.json`
* Shield统计文件`data/shield_stats.json`
* 本地规则文件:`data/rules.txt`
* Hosts文件`data/hosts.txt`
* 远程规则缓存目录:`data/remote_rules`