wgconf/conf/storewatcher.go
Vincent Batts 77158f3dde
conf: add from wireguard-windows/conf/@b73dcdb
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2021-04-21 07:03:18 -04:00

24 lines
438 B
Go

/* SPDX-License-Identifier: MIT
*
* Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
*/
package conf
type StoreCallback struct {
cb func()
}
var storeCallbacks = make(map[*StoreCallback]bool)
func RegisterStoreChangeCallback(cb func()) *StoreCallback {
startWatchingConfigDir()
cb()
s := &StoreCallback{cb}
storeCallbacks[s] = true
return s
}
func (cb *StoreCallback) Unregister() {
delete(storeCallbacks, cb)
}