formatting

This commit is contained in:
Daylin Morgan 2024-08-16 15:39:21 -05:00
parent 6774069a4f
commit d92e70162f
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 15 additions and 19 deletions

View file

@ -20,7 +20,9 @@
{ {
packages = forAllSystems (pkgs: rec { packages = forAllSystems (pkgs: rec {
utils = pkgs.callPackage ./meta.nix { inherit tunnel; }; utils = pkgs.callPackage ./meta.nix { inherit tunnel; };
tunnel = pkgs.callPackage ./tunnel-go { }; tunnel-go = pkgs.callPackage ./tunnel-go { };
tunnel-nim = pkgs.callPackage ./tunnel-nim { };
tunnel = tunnel-nim;
default = utils; default = utils;
}); });
devShells = forAllSystems (pkgs: { devShells = forAllSystems (pkgs: {

View file

@ -1,22 +1,16 @@
import std/[os, osproc, sequtils, strformat, strutils, sugar] import std/[os, osproc, sequtils, strformat, strutils, sugar]
import cligen import cligen
proc checkHost(host: seq[string]): string = proc checkHost(host: seq[string]): string =
case host.len: case host.len:
of 0: quit "expected hostname"
of 1: return host[0] of 1: return host[0]
of 0: quit "expected hostname"
else: quit "expected one positinal argument" else: quit "expected one positinal argument"
proc check(name: string): bool = (execCmd &"ssh -O check {name}") == 0
proc check(name: string): bool = proc startSsh(name: string) = discard execCmd &"ssh -M -f -N {name}"
(execCmd &"ssh -O check {name}") == 0 proc activateTunnel(name: string, port: int): int = execCmd &"""ssh -fNL "{port}:localhost:{port}" {name}"""
proc startSsh(name: string) = proc exitSsh(name: string):int = execCmd &"ssh -O exit {name}"
discard execCmd &"ssh -M -f -N {name}"
proc activateTunnel(name: string, port: int): int =
execCmd &"""ssh -fNL "{port}:localhost:{port}" {name}"""
proc exitSsh(name: string):int =
execCmd &"ssh -O exit {name}"
proc up(port: int, host: seq[string]) = proc up(port: int, host: seq[string]) =
## activate a tunnel ## activate a tunnel