fix: use Clash API only for traffic stats on stock sing-box builds

Official sing-box binaries lack v2ray_api, so drop that config and grpcio
and track per-node traffic from Clash connection stats instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-16 10:02:41 +08:00
parent ccf7e2a4c7
commit 6edba863b5
5 changed files with 106 additions and 181 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ bash scripts/install.sh
| 复制链接 | VLESS Reality + Hysteria2 分享链接 |
| 删除节点 | 至少保留 1 个节点 |
| 连接状态 | 在线/离线、当前连接数(Clash API) |
| 流量统计 | 实时速率 + 累计上下行(V2Ray 统计,重启 sing-box 后继续累计) |
| 流量统计 | 实时速率 + 累计上下行(Clash API 连接统计) |
---
+23 -4
View File
@@ -37,25 +37,44 @@ curl -I "http://66.hyf2.cc/$(grep ^PANEL_PATH= /opt/jiedian/.env | cut -d= -f2)/
> 443 端口已被 sing-box Reality 占用,面板走 80 端口子路径。请妥善保管 `PANEL_PATH`,相当于隐藏入口。
面板可查看每个节点的 **在线状态、连接数、实时速率、累计流量**(数据来自 sing-box Clash API + V2Ray 统计,仅监听 127.0.0.1)。
面板可查看每个节点的 **在线状态、连接数、实时速率、累计流量**(数据来自 sing-box Clash API,仅监听 127.0.0.1)。
> **注意**GitHub 官方 sing-box 预编译包**不含** `v2ray_api`,配置里不要启用 `experimental.v2ray_api`,否则 sing-box 无法启动。
---
## 常见问题
### sing-box 报错 v2ray api is not included in this build
GitHub 下载的官方 sing-box **默认不带** `v2ray_api` 模块。若配置里写了 `experimental.v2ray_api`,启动时会直接失败:
```
FATAL create v2ray-server: v2ray api is not included in this build, rebuild with -tags with_v2ray_api
```
**处理**:重新生成配置(已移除 v2ray_api,改用 Clash API 统计)并重启:
```bash
cd /opt/jiedian
git pull
python3 scripts/render-server.py
systemctl restart sing-box jiedian-panel
```
### 面板流量/在线状态显示「不可用」
sing-box 统计 API 未就绪,按顺序检查:
sing-box Clash API 未就绪,按顺序检查:
```bash
systemctl is-active sing-box
ss -tlnp | grep -E '9090|9091' # Clash API / V2Ray gRPC
ss -tlnp | grep 9090 # Clash API
grep CLASH_API_SECRET /opt/jiedian/.env
python3 /opt/jiedian/scripts/render-server.py
systemctl restart sing-box jiedian-panel
```
升级后若未重装,需重新生成 sing-box 配置并重启服务,才会启用 `experimental.clash_api``v2ray_api`
升级后若未重装,需重新生成 sing-box 配置并重启服务,才会启用 `experimental.clash_api`
### 在线状态始终离线但客户端能连