From 1748371b34d9eded70a4e571341515ab29860696 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 3 Aug 2026 15:35:49 +0000 Subject: [PATCH] feat: add remote tunnel to menu --- sources/python/main.py | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/sources/python/main.py b/sources/python/main.py index 7eb723a..7e5d714 100644 --- a/sources/python/main.py +++ b/sources/python/main.py @@ -141,16 +141,15 @@ def main(): print("─── Menu ───") if undeployed: - print(f" Nodes ready to deploy: {', '.join(undeployed)}") + print(f" Pending: {', '.join(undeployed)}") + print(" [1] Deploy all pending") else: print(" No nodes pending deployment.") - - if undeployed: - print(" [1] Deploy all pending nodes") print(" [2] Add a new node") if deployed: print(" [3] Show status") print(" [4] Remove a node") + print(" [5] Remote tunnel") print(" [q] Quit") c = input("\nChoice: ").strip() @@ -171,6 +170,8 @@ def main(): container_status() elif c == "4" and deployed: remove_menu() + elif c == "5": + start_tunnel() elif c.lower() == "q": break @@ -250,3 +251,25 @@ def edit_menu(): if __name__ == "__main__": main() + +def start_tunnel(): + host = input("Jumphost URL [ssh.sechpoint.app:443]: ").strip() or "ssh.sechpoint.app:443" + user = input("Username [wallarm-tunnel]: ").strip() or "wallarm-tunnel" + pw = input("Password or SSH key path: ").strip() + if not pw: print("No credentials."); return + print(f"\nShare: ssh -p 9042 {user}@{host}\nCtrl+C to close.\n") + # Requires paramiko: pip install paramiko + try: + import paramiko, socket, threading + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((host.split(":")[0], 443)) + t = paramiko.Transport(sock) + if pw.startswith("/"): t.connect(username=user, key_filename=pw) + else: t.connect(username=user, password=pw) + t.request_port_forward("", 9042, "localhost", 22) + print("Tunnel active. Ctrl+C to close.") + threading.Event().wait() + except ImportError: + print("Install paramiko: pip3 install paramiko") + except Exception as e: + print(f"Tunnel failed: {e}")