wintun: take mutex so that deletion uses the right name

This commit is contained in:
Jason A. Donenfeld
2019-08-29 17:42:28 -06:00
committed by Simon Rozman
parent 353f0956bc
commit 14df9c3e75
4 changed files with 84 additions and 25 deletions

View File

@@ -75,17 +75,11 @@ func CreateTUNWithRequestedGUID(ifname string, requestedGUID *windows.GUID) (Dev
return nil, fmt.Errorf("Unable to delete already existing Wintun interface: %v", err)
}
}
wt, _, err = WintunPool.CreateInterface(requestedGUID)
wt, _, err = WintunPool.CreateInterface(ifname, requestedGUID)
if err != nil {
return nil, fmt.Errorf("Unable to create Wintun interface: %v", err)
}
err = wt.SetName(ifname)
if err != nil {
wt.DeleteInterface()
return nil, fmt.Errorf("Unable to set name of Wintun interface: %v", err)
}
tun := &NativeTun{
wt: wt,
handle: windows.InvalidHandle,