ssssh more
This commit is contained in:
parent
1e826464cc
commit
60e088306a
1 changed files with 3 additions and 2 deletions
|
@ -3,13 +3,14 @@ import hwylterm, hwylterm/[hwylcli]
|
||||||
|
|
||||||
|
|
||||||
proc check(name: string): bool = (execCmd &"ssh -O check {name}") == 0
|
proc check(name: string): bool = (execCmd &"ssh -O check {name}") == 0
|
||||||
proc startSsh(name: string) = discard execCmd &"ssh -M -f -N {name}"
|
proc startSsh(name: string): int = (execCmdEx &"ssh -q -M -f -N {name}").exitCode
|
||||||
proc exitSsh(name: string): int = execCmd &"ssh -O exit {name}"
|
proc exitSsh(name: string): int = execCmd &"ssh -O exit {name}"
|
||||||
|
|
||||||
proc activateTunnel(name: string, port: int) =
|
proc activateTunnel(name: string, port: int) =
|
||||||
echo "activating connection to: ", name
|
echo "activating connection to: ", name
|
||||||
if not check(name):
|
if not check(name):
|
||||||
startSsh(name)
|
if startSsh(name) != 0:
|
||||||
|
quit "failed to start 'master' socket"
|
||||||
quit execCmd &"""ssh -fqNL "{port}:localhost:{port}" {name}"""
|
quit execCmd &"""ssh -fqNL "{port}:localhost:{port}" {name}"""
|
||||||
|
|
||||||
proc deactivateTunnels(name: string) =
|
proc deactivateTunnels(name: string) =
|
||||||
|
|
Loading…
Reference in a new issue