Caascad/toolbox

kswitch -t, --active-tunnel Show information about any active tunnel

Closed this issue · 2 comments

We already have this :

$ kswitch 
--- Current context is xxx
--- Tunnel is down: run kswitch xxx

Feature request

  • add an option --active-tunnel
  • return error code if tunnel is down (return 0 if tunnel is up&running)
$ kswitch --active-tunnel
Tunnel is down: run kswitch xxxx
$ echo $?
1
$ kswitch xxxx
...
$ kswitch --active-tunnel
Tunnel is active (pid=2704)
$ echo $?
0

Suggestion :

$ kswitch --help
Usage:
...
  kswitch -t, --active-tunnel    Show information about any active tunnel
...

Currently kswitch already exit with 1 when the tunnel is down

 kswitch
--- Current context is xxx
--- Tunnel is down: run kswitch xxx
 echo $?
1

I'm going to add a --json option for the status so it can be easily parsed

 kswitch  --json
{
    "context": "xxx",
    "tunnel": {
        "status": "up",
        "pid": 5198,
        "bastion": "user@fqdn",
        "zone": "xxx"
    }
}