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:
@@ -21,6 +21,7 @@ from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
|
||||
from db import add_node, delete_node, list_nodes, node_count, verify_admin
|
||||
from links import build_links, load_env
|
||||
from stats import collect_node_stats
|
||||
|
||||
ROOT = Path(os.environ.get("JIEDIAN_ROOT", Path(__file__).resolve().parents[1]))
|
||||
SECRET_FILE = ROOT / "data" / ".panel_secret"
|
||||
@@ -119,6 +120,12 @@ def dashboard():
|
||||
)
|
||||
|
||||
|
||||
@app.route("/api/stats", methods=["GET"])
|
||||
@login_required
|
||||
def api_stats():
|
||||
return jsonify(collect_node_stats())
|
||||
|
||||
|
||||
@app.route("/api/nodes", methods=["GET"])
|
||||
@login_required
|
||||
def api_list_nodes():
|
||||
|
||||
Reference in New Issue
Block a user