升级到 sing-box 1.12~1.14 后,不少用户的老配置启动直接报错 `geoip/geosite is deprecated or removed`。新版 sing-box 已全面采用按需加载的二进制规则集(`.srs`)替代笨重的全量数据库,内存占用降低超过 60%。下面给出可直接照抄的迁移写法。
旧写法 vs 新版 rule_set 写法对照
在旧版配置中,你可能在 route.rules 里写了 `"geosite": ["cn"]` 或 `"geoip": ["cn"]`。在新版 1.12+ 中,需要先在 `route.rule_set` 声明远程 `.srs` 规则源,再在 rules 中用 `rule_set` 字段引用。
{
"route": {
"rules": [
{ "action": "sniff" },
{ "protocol": "dns", "action": "hijack-dns" },
{ "ip_is_private": true, "outbound": "direct" },
{ "rule_set": ["geosite-cn", "geoip-cn"], "outbound": "direct" }
],
"rule_set": [
{
"tag": "geosite-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs",
"download_detour": "proxy"
},
{
"tag": "geoip-cn",
"type": "remote",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs",
"download_detour": "proxy"
}
],
"auto_detect_interface": true
}
}飓风传输 · 兼容 sing-box / SFI / SFA(每月低至 ¥5)
高速多协议节点,支持 VLESS / Trojan / Shadowsocks 与主流客户端订阅导入,稳定解锁海外流媒体与 AI。
1.12+ 另外两个高频报错顺手一起修
- 旧版 inbound 里的 `sniff: true` 与 `protocol: dns -> outbound: dns-out` 已改为路由规则里的 `action: sniff` 和 `action: hijack-dns`。
- 如果使用 `download_detour`,确保对应的出站 tag(例如 proxy)已在 outbounds 中定义,且本地开启 `experimental.cache_file.enabled: true` 缓存 .srs 文件避免每次重启重复拉取。
相关高频问答
怎么检查改好的 sing-box JSON 配置有没有语法错误?
在命令行执行 `sing-box check -c config.json`,若无输出且退出码为 0 即说明完全兼容当前版本内核。
国内首次下载 GitHub 上的 .srs 规则集失败怎么办?
把 `download_detour` 设为代理出站 tag,或者临时替换为国内镜像前缀,待 cache.db 缓存生成后离线重启也能直接使用。