tun: windows: switch to NDIS device object

This commit is contained in:
Jason A. Donenfeld 2019-07-18 12:26:57 +02:00
parent 298d759f3e
commit 6c50fedd8e
2 changed files with 6 additions and 7 deletions

View 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
}

View 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)