Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
46 lines
1.8 KiB
Python
46 lines
1.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
import sys, paramiko
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
REMOTE = r'''
|
|
python3 <<'PY'
|
|
import sqlite3, json, datetime
|
|
c=sqlite3.connect('/opt/frp-panel/data.db')
|
|
c.row_factory=sqlite3.Row
|
|
print('=== clients last_seen ===')
|
|
now=datetime.datetime.utcnow()
|
|
for r in c.execute('SELECT client_id, server_id, is_shadow, stopped, last_seen_at, updated_at FROM clients WHERE deleted_at IS NULL ORDER BY client_id'):
|
|
ls=r['last_seen_at']
|
|
age='never'
|
|
if ls:
|
|
try:
|
|
t=datetime.datetime.fromisoformat(str(ls).replace('Z','+00:00').split('+')[0])
|
|
age=f"{(now-t).total_seconds():.0f}s ago"
|
|
except Exception as e:
|
|
age=str(ls)[:40]
|
|
print(f"{r['client_id']:40} shadow={r['is_shadow']} stopped={r['stopped']} server={r['server_id'] or '-':20} last_seen={age}")
|
|
|
|
print('\n=== active proxy_config (not deleted) ===')
|
|
rows=c.execute('SELECT id,name,type,server_id,client_id,stopped FROM proxy_config WHERE deleted_at IS NULL ORDER BY id').fetchall()
|
|
print('count', len(rows))
|
|
for r in rows:
|
|
print(dict(r))
|
|
|
|
print('\n=== servers config plugin count ===')
|
|
for r in c.execute('SELECT server_id, ip, config_content FROM servers WHERE deleted_at IS NULL'):
|
|
cfg=r['config_content']
|
|
if isinstance(cfg, memoryview): cfg=bytes(cfg)
|
|
if isinstance(cfg, bytes): cfg=cfg.decode('utf-8','replace')
|
|
try:
|
|
j=json.loads(cfg or '{}')
|
|
except Exception:
|
|
j={}
|
|
plugins=j.get('httpPlugins') or []
|
|
print(r['server_id'], r['ip'], 'bindPort', j.get('bindPort'), 'plugins', len(plugins), plugins)
|
|
PY
|
|
'''
|
|
c=paramiko.SSHClient(); c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('107.172.77.34',22,'root','Xiao4669805',timeout=45,allow_agent=False,look_for_keys=False)
|
|
_,o,_=c.exec_command(REMOTE,timeout=60)
|
|
print(o.read().decode())
|
|
c.close()
|