feat: show node connection status and traffic stats in admin panel
Enable sing-box Clash/V2Ray APIs for per-user metrics, persist cumulative traffic in SQLite, and refresh the dashboard every five seconds. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -54,9 +54,14 @@ def build_config(env: dict[str, str], nodes: list[dict]) -> dict:
|
||||
raise SystemExit(f".env 缺少 {key}")
|
||||
|
||||
vless_users = [{"uuid": n["uuid"], "flow": "xtls-rprx-vision"} for n in nodes]
|
||||
hy2_users = [{"password": n["hy2_password"]} for n in nodes]
|
||||
# name 与 VLESS uuid 一致,便于 v2ray/clash API 按用户统计流量
|
||||
hy2_users = [
|
||||
{"name": n["uuid"], "password": n["hy2_password"]} for n in nodes
|
||||
]
|
||||
user_ids = [n["uuid"] for n in nodes]
|
||||
clash_secret = env.get("CLASH_API_SECRET", "")
|
||||
|
||||
return {
|
||||
config = {
|
||||
"log": {"level": "warn", "timestamp": True},
|
||||
"inbounds": [
|
||||
{
|
||||
@@ -100,6 +105,24 @@ def build_config(env: dict[str, str], nodes: list[dict]) -> dict:
|
||||
},
|
||||
}
|
||||
|
||||
experimental: dict = {
|
||||
"clash_api": {
|
||||
"external_controller": "127.0.0.1:9090",
|
||||
},
|
||||
"v2ray_api": {
|
||||
"listen": "127.0.0.1:9091",
|
||||
"stats": {
|
||||
"enabled": True,
|
||||
"inbounds": ["vless-reality-in", "hysteria2-in"],
|
||||
"users": user_ids,
|
||||
},
|
||||
},
|
||||
}
|
||||
if clash_secret:
|
||||
experimental["clash_api"]["secret"] = clash_secret
|
||||
config["experimental"] = experimental
|
||||
return config
|
||||
|
||||
|
||||
def main() -> None:
|
||||
env = load_env(ENV_FILE)
|
||||
|
||||
Reference in New Issue
Block a user