Major changes: - TUN mode: tun2socks + xray SOCKS architecture (replaced sing-box) - Hot-swap: node switching keeps TUN alive, only restarts xray - Traffic graph: live QPainter chart on dashboard with detail dialog - Settings: stock qfluentwidgets cards (SpinBox, ColorPicker, PushSettingCard) - Navigation: fixed icon/text overlap in expanded menu - Ctrl+V import, copy link from context menu - System proxy cleanup on exit (atexit safety net) - Build: data/ backup/restore during PyInstaller rebuild - Log throttling in TUN mode to prevent UI freeze Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
import json
|
|
from pathlib import Path
|
|
import platform
|
|
import zipfile
|
|
|
|
from .models import AppState
|
|
|
|
|
|
REDACT_KEYS = {
|
|
"id",
|
|
"password",
|
|
"pass",
|
|
"token",
|
|
"publicKey",
|
|
"privateKey",
|
|
"shortId",
|
|
"sid",
|
|
"uuid",
|
|
}
|
|
|
|
|
|
def _redact(value):
|
|
if isinstance(value, dict):
|
|
redacted = {}
|
|
for key, item in value.items():
|
|
if key in REDACT_KEYS:
|
|
redacted[key] = "***"
|
|
else:
|
|
redacted[key] = _redact(item)
|
|
return redacted
|
|
if isinstance(value, list):
|
|
return [_redact(item) for item in value]
|
|
return value
|
|
|
|
|
|
def export_diagnostics(zip_path: Path, state: AppState, logs: list[str]) -> Path:
|
|
zip_path.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
safe_state = _redact(state.to_dict())
|
|
meta = {
|
|
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
"platform": platform.platform(),
|
|
"python": platform.python_version(),
|
|
}
|
|
|
|
with zipfile.ZipFile(zip_path, "w", compression=zipfile.ZIP_DEFLATED) as archive:
|
|
archive.writestr("state_redacted.json", json.dumps(safe_state, ensure_ascii=True, indent=2))
|
|
archive.writestr("meta.json", json.dumps(meta, ensure_ascii=True, indent=2))
|
|
archive.writestr("recent_logs.txt", "\n".join(logs[-2000:]))
|
|
|
|
return zip_path
|