This commit is contained in:
Penguinehis
2026-09-29 11:55:30 -03:00
parent 8a0859bb7a
commit 81d71999b4
3 changed files with 66 additions and 12 deletions
+32 -11
View File
@@ -467,10 +467,10 @@ def xray_inbounds():
print_wrapped(f"{inbound.get('tag')} ({inbound.get('protocol')}/{inbound.get('network') or 'tcp'}, "
f"{endpoint}, path {inbound.get('path') or '-'})")
for c in inbound.get("clients") or []:
print_wrapped(f"{c.get('name') or c.get('email') or c.get('uuid')} "
print_wrapped(f"{c.get('name') or c.get('email') or c.get('id') or c.get('uuid')} "
f"online={c.get('online', False)} "
f"usage={size(c.get('total_bytes', 0))}", " ")
print_wrapped(str(c.get('uuid')), " ")
print_wrapped(str(c.get('id') or c.get('uuid')), " ")
return inbounds
@@ -590,7 +590,8 @@ def xray_delete():
def xray_edit():
client_uuid = ask("Client UUID")
client = next((c for inbound in request("GET", "/api/xray/inbounds") or []
for c in inbound.get("clients") or [] if c.get("uuid") == client_uuid), None)
for c in inbound.get("clients") or []
if (c.get("id") or c.get("uuid")) == client_uuid), None)
if not client:
raise CLIError("Xray client not found")
p = {"uuid": client_uuid, "name": client.get("name") or "",
@@ -842,23 +843,43 @@ def render_menu(title, options, vps_status=None, columns=None):
return "\n".join(lines)
def clear_screen():
if sys.stdout.isatty():
sys.stdout.write("\033[2J\033[H")
sys.stdout.flush()
_menu_calls = 0
def menu(title, options):
global _menu_calls
_menu_calls += 1
while True:
clear_screen()
vps = collect_vps_status() if title == "MAIN MENU" else None
print("\n" + render_menu(title, options, vps))
print(render_menu(title, options, vps))
choice = input("Choose: ").strip().lstrip("0") or "0"
if choice == "0":
return
entry = options.get(choice)
if not entry:
print("Invalid option.")
continue
try:
entry[1]()
except (CLIError, ValueError, json.JSONDecodeError, OSError) as exc:
print("Error:", exc)
except KeyboardInterrupt:
print("\nCancelled.")
else:
current_menu_calls = _menu_calls
try:
entry[1]()
except (CLIError, ValueError, json.JSONDecodeError, OSError) as exc:
print("Error:", exc)
except KeyboardInterrupt:
print("\nCancelled.")
if _menu_calls != current_menu_calls:
continue # A submenu already showed its own output and prompts.
if sys.stdin.isatty() and sys.stdout.isatty():
try:
input("\nPress Enter to return to menu...")
except (EOFError, KeyboardInterrupt):
print()
def ssh_menu():