Rogue 3e052c42b8 feat(probe): history store + whole-machine traffic ledger in probe.db (item 7 B2)
New internal/web/service/probe package keeps probe history in its own
probe.db beside the panel DB (single connection, WAL), so history
writes never contend with the panel write lock.

- Minute rows per hub semantics: a held-reading rhythm books traffic
  against each reading own arrival; minute buckets merge (means,
  rounded int means, peaks) and the stored net rate derives from the
  kernel counters between row marks, falling back to agent rates at
  epoch breaks.
- probe_traffic ledger: accumulate is a line port of hub traffic.rs
  (baseline alignment, same-boot shrink books 0, epoch change books 0,
  unseen-boot exception books the whole counters-since-boot measured
  against the master last-seen stamp, per-direction period resets,
  saturating adds); reads gate stale day/month stamps to zero.
- probe_meta rows are ensured for every reporting agent (B3 edits
  them in place); probe_ping_* tables are created now, written by B4.
- Hourly roll_up behind a watermark (hour-aligned, late grace,
  pre-retention hours skipped unfoldered) and watermark-guarded
  chunked prune (minute tier 7 days or the retention window when
  shorter; hourly tier to retention_days, default 7, cap 365).
- Wiring: heartbeat files probe samples after the snapshot update
  (last-seen captured before touch); housekeeping hangs off the
  existing robfig/cron in web.startTask (@hourly + one pass a minute
  after startup, mirroring the hub boot pass); Server.stop books held
  readings. Every failure path logs and degrades - a broken probe.db
  never fails a heartbeat or the panel.
2026-10-22 19:43:59 +00:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00
2026-08-24 15:07:15 +02:00

3x-ui-agent

基于上游 3x-ui v3.7.0 的二次开发 fork:节点 agent 化。节点鸡不再跑完整面板,只跑一个轻量 agent(约 60MB 内存),由主控统一管理、下发 xray 配置。

本仓库托管在自建 Gitea:https://git.881218.xyz/rogue/3x-ui-agent,二进制从本仓库的 Releases 下载。不要使用上游的一键安装脚本/命令(install.sh、update.sh 等仍指向原版,会装成上游原版,与本 fork 不兼容)。

架构

  • 主控:完整 3x-ui 面板,唯一的配置可信源。管理节点、入站、客户端,下发完整 xray 配置(含出站、路由)到各 agent。
  • Agent:跑在节点鸡上,通过注册 token 向主控注册。定时拉取主控下发的 xray 配置并应用,上报心跳和流量。节点下发仅支持 VLESS / SS2022 两类入站(本 fork 的取向)。

同一个二进制、两种角色:不带参数运行是主控面板,x-ui agent --config /etc/x-ui/agent.json 运行是 agent。

安装

二进制下载:本仓库 Releases,按架构选 x-ui-linux-amd64 或 x-ui-linux-arm64。

仓库根目录的 install-master.sh / install-agent.sh 是一键脚本,下载源已迁至本仓 Gitea Releases(tag v3.7.0-agent.1),可直接使用;也可按下面步骤手动部署。

主控

mkdir -p /usr/local/x-ui/bin /etc/x-ui

# 1. 放主控二进制(Releases 下载的 x-ui-linux-<架构>)
cp x-ui-linux-amd64 /usr/local/x-ui/x-ui && chmod +x /usr/local/x-ui/x-ui

# 2. 放 xray 二进制与 geo 文件到 bin/ 子目录
#    纯控制面部署(节点全走 agent)可禁用本机 xray:不放,或放了之后 chmod -x
cp xray-linux-amd64 /usr/local/x-ui/bin/
cp geoip.dat geosite.dat /usr/local/x-ui/bin/

启动(二选一):

  • Debian/Ubuntu(systemd):把仓库的 x-ui.service.debian 复制为 /etc/systemd/system/x-ui.service,然后 systemctl daemon-reload && systemctl enable --now x-ui。
  • OpenWrt(procd):用 init 脚本以 /usr/local/x-ui/x-ui 为命令启动,工作目录 /usr/local/x-ui。

数据库在 /etc/x-ui/x-ui.db。面板端口按设置,默认 2053,首次登录默认账号 admin / admin,请登录后立即修改。

Agent(节点鸡)

先在主控侧为该节点生成注册 token(建节点 → 用面板 API Token 签发绑定该节点的 agent token,完整步骤见 docs/AGENT.md),然后在节点鸡上:

mkdir -p /usr/local/x-ui/bin /etc/x-ui

# 1. 放同一个二进制(与主控同版本),在节点上改名为 xui-agent(与主控进程区分、避免同机覆盖)
cp x-ui-linux-amd64 /usr/local/x-ui/xui-agent && chmod +x /usr/local/x-ui/xui-agent

# 2. 放 xray 二进制与 geo 文件(agent 不负责下载,需手动放置)
cp xray-linux-amd64 /usr/local/x-ui/bin/xray && chmod +x /usr/local/x-ui/bin/xray
cp geoip.dat geosite.dat /usr/local/x-ui/bin/

# 3. 写 agent 配置
cat > /etc/x-ui/agent.json <<'EOF'
{
  "master_url": "http://主控地址:2053",
  "token": "<主控签发的注册 token>",
  "node_name": "节点名"
}
EOF
chmod 600 /etc/x-ui/agent.json
  • master_url 走内网用 http://;走 https:// 需可信证书(自签连不上)。
  • agent 另有独立的运行时配置 config-agent.json(生成于 bin/);agent.json 可选 api_port 指定 xray stats API 端口(部署口径 62790,metrics 端口为其下一位 62791)。
  • 启动:Debian 把仓库的 systemd/x-ui-agent.service 复制到 /etc/systemd/system/ 后 systemctl enable --now x-ui-agent;OpenRC 用仓库的 openrc/x-ui-agent 放到 /etc/init.d/x-ui-agent。

agent 约 30 秒后拉到配置并启动 xray,节点在面板显示在线。更细的 agent 说明(出站/路由下发、验证、故障排查)见 docs/AGENT.md。

卸载

主控

# 先停服务:systemctl disable --now x-ui(或 /etc/init.d/x-ui stop)
rm -f /etc/systemd/system/x-ui.service   # 或删掉对应的 procd init 脚本
rm -rf /usr/local/x-ui /etc/x-ui

Agent

# 先停服务:systemctl disable --now x-ui-agent(或 rc-service x-ui-agent stop)
rm -f /etc/systemd/system/x-ui-agent.service   # 或 /etc/init.d/x-ui-agent
rm -rf /usr/local/x-ui /etc/x-ui

(/etc/x-ui 里含数据库与 token 配置,确认不再需要再删。)

使用流程

  1. 主控侧建节点并签发 agent 注册 token(见 docs/AGENT.md)
  2. 节点鸡按上面步骤部署 agent,填入主控地址和 token
  3. 在「入站列表」创建入站(VLESS / SS2022),「部署到」选择在线的 agent 节点
  4. 主控自动把完整 xray 配置下发到节点,客户端即可连接

内存占用(实测)

内存
agent + xray 约 63MB
完整 3x-ui 面板 130–160MB

另有路由器主控精简版构建(剥离 xray-core 库,见仓库内 PANEL-LITE-SPEC.md),面向纯控制面部署,内存显著更低。

与原版的区别

  • 节点不再需要安装完整面板
  • 主控是唯一可信源,节点配置全部由主控下发
  • 节点在线状态由 agent 心跳维持
  • 添加节点支持 Agent 类型,使用注册 token 接入

License

GPL-3.0(继承上游 3x-ui)

S
Description
No description provided
Readme GPL-3.0
96 MiB
V2.2.1
Latest
2026-10-23 23:30:59 +08:00
Languages
Go 67.2%
TypeScript 29%
Shell 2.4%
CSS 1%
JavaScript 0.3%