From 6c50fedd8eecc6cb06d8da47514794eb211d5b3a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 18 Jul 2019 12:26:57 +0200 Subject: tun: windows: switch to NDIS device object --- tun/tun_windows.go | 8 ++++++-- tun/wintun/wintun_windows.go | 5 ----- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'tun') diff --git a/tun/tun_windows.go b/tun/tun_windows.go index d22e130..21bc382 100644 --- a/tun/tun_windows.go +++ b/tun/tun_windows.go @@ -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 } diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go index 160d51f..e8eadf5 100644 --- a/tun/wintun/wintun_windows.go +++ b/tun/wintun/wintun_windows.go @@ -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) -- cgit v1.2.3