]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
tun: windows: switch to NDIS device object
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 18 Jul 2019 10:26:57 +0000 (12:26 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Thu, 18 Jul 2019 10:26:57 +0000 (12:26 +0200)
tun/tun_windows.go
tun/wintun/wintun_windows.go

index d22e13082a3baa361748a714c5b8774281affc2c..21bc38288e41904bb974111b4dc5697dd8fc5570 100644 (file)
@@ -146,13 +146,17 @@ func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (Dev
 }
 
 func (tun *NativeTun) openTUN() error {
+       filename, err := tun.wt.NdisFileName()
+       if err != nil {
+               return err
+       }
+
        retries := maybeRetry(retryTimeout * retryRate)
        if tun.close {
                return os.ErrClosed
        }
 
-       var err error
-       name, err := windows.UTF16PtrFromString(tun.wt.DataFileName())
+       name, err := windows.UTF16PtrFromString(filename)
        if err != nil {
                return err
        }
index 160d51f80c0cef5c08a85544b3cbba43b43580f9..e8eadf5f27401943dd365a539baacc7dc4cfb86e 100644 (file)
@@ -612,11 +612,6 @@ func (wintun *Wintun) deviceData() (setupapi.DevInfo, *setupapi.DevInfoData, err
        return 0, nil, windows.ERROR_OBJECT_NOT_FOUND
 }
 
-// DataFileName returns the Wintun device data pipe name.
-func (wintun *Wintun) DataFileName() string {
-       return fmt.Sprintf("\\\\.\\Global\\WINTUN%d", wintun.luidIndex)
-}
-
 // NdisFileName returns the Wintun NDIS device object name.
 func (wintun *Wintun) NdisFileName() (string, error) {
        key, err := registry.OpenKey(registry.LOCAL_MACHINE, wintun.netRegKeyName(), registry.QUERY_VALUE)