feat: add remote tunnel to menu

This commit is contained in:
admin 2026-08-03 15:35:49 +00:00
parent aba98108b0
commit 1748371b34

View file

@ -141,16 +141,15 @@ def main():
print("─── Menu ───") print("─── Menu ───")
if undeployed: if undeployed:
print(f" Nodes ready to deploy: {', '.join(undeployed)}") print(f" Pending: {', '.join(undeployed)}")
print(" [1] Deploy all pending")
else: else:
print(" No nodes pending deployment.") print(" No nodes pending deployment.")
if undeployed:
print(" [1] Deploy all pending nodes")
print(" [2] Add a new node") print(" [2] Add a new node")
if deployed: if deployed:
print(" [3] Show status") print(" [3] Show status")
print(" [4] Remove a node") print(" [4] Remove a node")
print(" [5] Remote tunnel")
print(" [q] Quit") print(" [q] Quit")
c = input("\nChoice: ").strip() c = input("\nChoice: ").strip()
@ -171,6 +170,8 @@ def main():
container_status() container_status()
elif c == "4" and deployed: elif c == "4" and deployed:
remove_menu() remove_menu()
elif c == "5":
start_tunnel()
elif c.lower() == "q": elif c.lower() == "q":
break break
@ -250,3 +251,25 @@ def edit_menu():
if __name__ == "__main__": if __name__ == "__main__":
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}")