feat: add remote tunnel to menu
This commit is contained in:
parent
aba98108b0
commit
1748371b34
1 changed files with 27 additions and 4 deletions
|
|
@ -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}")
|
||||
|
|
|
|||
Loading…
Reference in a new issue