feat(agent): WARP 域名分流 —— 命中域名走 Cloudflare 干净出口(#29)
节点 sing-box 渲染新增可选 WARP 分流:节点本地 warp.json(默认 <StateDir>/warp.json)配 WARP 凭证 + 域名清单 → 渲染时注入一个 userspace WireGuard(WARP)endpoint + route(sniff 取 SNI/Host → domain_suffix 命中走 warp,其余 final=direct)。sing-box 1.11+ endpoints 语法,system=false 用户态 不依赖内核 wg 模块。 - 运营改域名只需编辑 warp.json + 重启 agent(sing-box 无热重载),即「配置的方式」。 - warp.json 不存在/enabled=false/域名空/凭证缺/坏 JSON → 一律按未启用,配置与旧 节点逐字节一致,坏配置绝不产出无法启动的 sing-box config(渲染读失败仅记日志)。 - WARP 凭证节点私有(wgcf 注册免费匿名账号),不入 git、不经控制面。 - 测试:注入 endpoint+route/无配置无 route/禁用或残缺不注入/坏 JSON 优雅退化。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -315,7 +315,15 @@ func (s *SingBox) RenderConfig() ([]byte, error) {
|
||||
hy2 := s.hy2
|
||||
s.mu.Unlock()
|
||||
sort.Slice(creds, func(i, j int) bool { return creds[i].DpUUID < creds[j].DpUUID })
|
||||
return renderSingboxConfig(creds, reality, hy2, s.cfg.DeriveKey)
|
||||
|
||||
// WARP 分流配置每次渲染读一次:编辑 warp.json 后任一渲染(或 agent 重启)即生效(#29)。
|
||||
// 读失败(坏 JSON)仅记日志、按未启用处理,绝不因坏配置产出无法启动的 sing-box 配置。
|
||||
warp, err := LoadWarpConfig(s.cfg.WarpConfigPath)
|
||||
if err != nil {
|
||||
logf("[warp] load %s failed, WARP routing disabled: %v", s.cfg.WarpConfigPath, err)
|
||||
warp = nil
|
||||
}
|
||||
return renderSingboxConfig(creds, reality, hy2, s.cfg.DeriveKey, warp)
|
||||
}
|
||||
|
||||
// writeAndRestart renders, writes the config file and restarts sing-box.
|
||||
|
||||
Reference in New Issue
Block a user