diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-02 05:18:40 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-02 05:18:40 +0100 |
commit | 7d36922a3cb9d77e9c4ba4db3f70b34bc65b27dd (patch) | |
tree | e66ffb1e2b23aeba9f54c8f10eeaf02cdaa355cb /service/service_tunnel.go | |
parent | ifaceconfig: allow for null defaults (diff) | |
download | wireguard-windows-7d36922a3cb9d77e9c4ba4db3f70b34bc65b27dd.tar.xz wireguard-windows-7d36922a3cb9d77e9c4ba4db3f70b34bc65b27dd.zip |
ifaceconfig: monitor for changes to default interface
Diffstat (limited to '')
-rw-r--r-- | service/service_tunnel.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/service/service_tunnel.go b/service/service_tunnel.go index 750a4302..12a0d709 100644 --- a/service/service_tunnel.go +++ b/service/service_tunnel.go @@ -8,6 +8,7 @@ package service import ( "bufio" "fmt" + "golang.zx2c4.com/winipcfg" "log" "strings" @@ -131,8 +132,9 @@ func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest, return } ipcSetOperation(device, bufio.NewReader(strings.NewReader(uapiConf))) + guid := wintun.(*tun.NativeTun).GUID() - err = monitorDefaultRoutes(device.net.bind.(*NativeBind)) + routeMonitorCallback, err := monitorDefaultRoutes(device.net.bind.(*NativeBind), &guid) if err != nil { logger.Error.Println("Unable to bind sockets to default route:", err) changes <- svc.Status{State: svc.StopPending} @@ -141,7 +143,6 @@ func (service *tunnelService) Execute(args []string, r <-chan svc.ChangeRequest, return } - guid := wintun.(*tun.NativeTun).GUID() err = configureInterface(conf, &guid) if err != nil { logger.Error.Println("Unable to set interface addresses, routes, DNS, or IP settings:", err) @@ -174,6 +175,7 @@ loop: changes <- svc.Status{State: svc.StopPending} logger.Info.Println("Shutting down") + winipcfg.UnregisterRouteChangeCallback(routeMonitorCallback) uapi.Close() device.Close() return |