aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/service/ifaceconfig.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-10 21:32:34 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-10 21:32:56 +0200
commitddfe4c59314cc69efc79c24d94fcc9eb72b331b0 (patch)
treeab20e2ae1479654213765a5d1f33aedfc3dbcdd2 /service/ifaceconfig.go
parentversion: bump (diff)
downloadwireguard-windows-ddfe4c59314cc69efc79c24d94fcc9eb72b331b0.tar.xz
wireguard-windows-ddfe4c59314cc69efc79c24d94fcc9eb72b331b0.zip
service: use LUID directly
InterfaceGuidToLuid fails if called soon after device creation. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'service/ifaceconfig.go')
-rw-r--r--service/ifaceconfig.go20
1 files changed, 5 insertions, 15 deletions
diff --git a/service/ifaceconfig.go b/service/ifaceconfig.go
index d52dbc55..c6458b4e 100644
--- a/service/ifaceconfig.go
+++ b/service/ifaceconfig.go
@@ -51,16 +51,12 @@ func bindSocketRoute(family winipcfg.AddressFamily, device *device.Device, ourLu
}
func monitorDefaultRoutes(device *device.Device, autoMTU bool, tun *tun.NativeTun) (*winipcfg.RouteChangeCallback, error) {
- guid := tun.GUID()
- ourLuid, err := winipcfg.InterfaceGuidToLuid(&guid)
+ ourLuid := tun.LUID()
lastLuid4 := uint64(0)
lastLuid6 := uint64(0)
lastMtu := uint32(0)
- if err != nil {
- return nil, err
- }
doIt := func() error {
- err = bindSocketRoute(winipcfg.AF_INET, device, ourLuid, &lastLuid4)
+ err := bindSocketRoute(winipcfg.AF_INET, device, ourLuid, &lastLuid4)
if err != nil {
return err
}
@@ -120,7 +116,7 @@ func monitorDefaultRoutes(device *device.Device, autoMTU bool, tun *tun.NativeTu
}
return nil
}
- err = doIt()
+ err := doIt()
if err != nil {
return nil, err
}
@@ -181,8 +177,7 @@ func cleanupAddressesOnDisconnectedInterfaces(addresses []*net.IPNet) {
}
func configureInterface(conf *conf.Config, tun *tun.NativeTun) error {
- guid := tun.GUID()
- iface, err := winipcfg.InterfaceFromGUID(&guid)
+ iface, err := winipcfg.InterfaceFromLUID(tun.LUID())
if err != nil {
return err
}
@@ -319,11 +314,6 @@ func configureInterface(conf *conf.Config, tun *tun.NativeTun) error {
}
func enableFirewall(conf *conf.Config, tun *tun.NativeTun) error {
- guid := tun.GUID()
- luid, err := winipcfg.InterfaceGuidToLuid(&guid)
- if err != nil {
- return err
- }
restrictDNS := len(conf.Interface.Dns) > 0
restrictAll := false
if len(conf.Peers) == 1 {
@@ -344,5 +334,5 @@ func enableFirewall(conf *conf.Config, tun *tun.NativeTun) error {
name, _ := tun.Name()
log.Printf("[%s] Warning: no DNS server specified, despite having an allowed IPs of 0.0.0.0/0 or ::/0. There may be connectivity issues.", name)
}
- return firewall.EnableFirewall(luid, restrictDNS, restrictAll)
+ return firewall.EnableFirewall(tun.LUID(), restrictDNS, restrictAll)
}