diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-26 20:05:24 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-04-27 08:24:22 +0200 |
commit | d099b3eda13bda85a3763cb7a73543999c35e11f (patch) | |
tree | d62408b62529d0e18a19866d540c1c87cfa957c1 /service/ipc_client.go | |
parent | installer: new checksums for working msm (diff) | |
download | wireguard-windows-d099b3eda13bda85a3763cb7a73543999c35e11f.tar.xz wireguard-windows-d099b3eda13bda85a3763cb7a73543999c35e11f.zip |
ui: simplify everything
Diffstat (limited to '')
-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) |