diff options
Diffstat (limited to 'service/ipc_client.go')
-rw-r--r-- | service/ipc_client.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/service/ipc_client.go b/service/ipc_client.go index e6295b91..55fc043d 100644 --- a/service/ipc_client.go +++ b/service/ipc_client.go @@ -113,6 +113,20 @@ func (t *Tunnel) Stop() error { return rpcClient.Call("ManagerService.Stop", t.Name, nil) } +func (t *Tunnel) Toggle() (oldState TunnelState, err error) { + oldState, err = t.State() + if err != nil { + oldState = TunnelUnknown + return + } + if oldState == TunnelStarted { + err = t.Stop() + } else if oldState == TunnelStopped { + err = t.Start() + } + return +} + func (t *Tunnel) WaitForStop() error { return rpcClient.Call("ManagerService.WaitForStop", t.Name, nil) } @@ -136,6 +150,11 @@ func IPCClientTunnels() ([]Tunnel, error) { return tunnels, rpcClient.Call("ManagerService.Tunnels", uintptr(0), &tunnels) } +func IPCClientGlobalState() (TunnelState, error) { + var state TunnelState + return state, rpcClient.Call("ManagerService.GlobalState", uintptr(0), &state) +} + func IPCClientQuit(stopTunnelsOnQuit bool) (bool, error) { var alreadyQuit bool return alreadyQuit, rpcClient.Call("ManagerService.Quit", stopTunnelsOnQuit, &alreadyQuit) |