From 2a04175238431a128a5bb6a49532c5eb395938fa Mon Sep 17 00:00:00 2001 From: braginini Date: Mon, 10 Apr 2023 10:44:31 +0200 Subject: [PATCH] Fix windows tun GUID --- iface/tun_windows.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/iface/tun_windows.go b/iface/tun_windows.go index 5f395d877..78ca65371 100644 --- a/iface/tun_windows.go +++ b/iface/tun_windows.go @@ -5,11 +5,9 @@ import ( "github.com/netbirdio/netbird/iface/bind" "github.com/pion/transport/v2" log "github.com/sirupsen/logrus" - "golang.org/x/sys/windows" "golang.zx2c4.com/wireguard/device" "golang.zx2c4.com/wireguard/ipc" "golang.zx2c4.com/wireguard/tun" - "golang.zx2c4.com/wireguard/windows/driver" "golang.zx2c4.com/wireguard/windows/tunnel/winipcfg" "net" ) @@ -95,8 +93,8 @@ func (c *tunDevice) getInterfaceGUIDString() (string, error) { if c.netInterface == nil { return "", fmt.Errorf("interface has not been initialized yet") } - windowsDevice := c.netInterface.(*driver.Adapter) - luid := windowsDevice.LUID() + windowsDevice := c.netInterface.(*tun.NativeTun) + luid := winipcfg.LUID(windowsDevice.LUID()) guid, err := luid.GUID() if err != nil { return "", err @@ -104,22 +102,6 @@ func (c *tunDevice) getInterfaceGUIDString() (string, error) { return guid.String(), nil } -func (c *tunDevice) createAdapter() (NetInterface, error) { - WintunStaticRequestedGUID, _ := windows.GenerateGUID() - adapter, err := driver.CreateAdapter(c.name, "WireGuard", &WintunStaticRequestedGUID) - if err != nil { - err = fmt.Errorf("error creating adapter: %w", err) - return nil, err - } - err = adapter.SetAdapterState(driver.AdapterStateUp) - if err != nil { - return adapter, err - } - state, _ := adapter.LUID().GUID() - log.Debugln("device guid: ", state.String()) - return adapter, nil -} - // assignAddr Adds IP address to the tunnel interface and network route based on the range provided func (c *tunDevice) assignAddr() error { tunDev := c.netInterface.(*tun.NativeTun)