aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-03 01:59:14 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-03 02:07:53 +0100
commit79eb071e6a661b9b3df14df9791558eb03c4c8b9 (patch)
tree32d37253d5248de6bbc42241bbeaefd205c5d7ee
parentipc: work out service state transitions (diff)
downloadwireguard-windows-79eb071e6a661b9b3df14df9791558eb03c4c8b9.tar.xz
wireguard-windows-79eb071e6a661b9b3df14df9791558eb03c4c8b9.zip
callbacks: use cb as receiver for unregister
-rw-r--r--conf/storewatcher.go10
-rw-r--r--service/ipc_client.go4
-rw-r--r--service/service_tunnel.go3
3 files changed, 8 insertions, 9 deletions
diff --git a/conf/storewatcher.go b/conf/storewatcher.go
index 7a5ab387..ffd20ee0 100644
--- a/conf/storewatcher.go
+++ b/conf/storewatcher.go
@@ -5,20 +5,20 @@
package conf
-type storeCallback struct {
+type StoreCallback struct {
cb func()
}
-var storeCallbacks = make(map[*storeCallback]bool)
+var storeCallbacks = make(map[*StoreCallback]bool)
-func RegisterStoreChangeCallback(cb func()) *storeCallback {
+func RegisterStoreChangeCallback(cb func()) *StoreCallback {
startWatchingConfigDir()
cb()
- s := &storeCallback{cb}
+ s := &StoreCallback{cb}
storeCallbacks[s] = true
return s
}
-func UnregisterStoreChangeCallback(cb *storeCallback) {
+func (cb *StoreCallback) Unregister() {
delete(storeCallbacks, cb)
}
diff --git a/service/ipc_client.go b/service/ipc_client.go
index 6834e10e..adaca0b7 100644
--- a/service/ipc_client.go
+++ b/service/ipc_client.go
@@ -134,7 +134,7 @@ func IPCClientRegisterTunnelChange(cb func(tunnel *Tunnel, state TunnelState)) *
tunnelChangeCallbacks[s] = true
return s
}
-func IPCClientUnregisterTunnelChange(cb *TunnelChangeCallback) {
+func (cb *TunnelChangeCallback) Unregister() {
delete(tunnelChangeCallbacks, cb)
}
func IPCClientRegisterTunnelsChange(cb func()) *TunnelsChangeCallback {
@@ -142,6 +142,6 @@ func IPCClientRegisterTunnelsChange(cb func()) *TunnelsChangeCallback {
tunnelsChangeCallbacks[s] = true
return s
}
-func IPCClientUnregisterTunnelsChange(cb *TunnelsChangeCallback) {
+func (cb *TunnelsChangeCallback) Unregister() {
delete(tunnelsChangeCallbacks, cb)
}
diff --git a/service/service_tunnel.go b/service/service_tunnel.go
index 12a0d709..6eff6fa5 100644
--- a/service/service_tunnel.go
+++ b/service/service_tunnel.go
@@ -8,7 +8,6 @@ package service
import (
"bufio"
"fmt"
- "golang.zx2c4.com/winipcfg"
"log"
"strings"
@@ -175,7 +174,7 @@ loop:
changes <- svc.Status{State: svc.StopPending}
logger.Info.Println("Shutting down")
- winipcfg.UnregisterRouteChangeCallback(routeMonitorCallback)
+ routeMonitorCallback.Unregister()
uapi.Close()
device.Close()
return