tun: windows: Make adapter rename asynchronous
Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
41c30a7279
commit
2faf2dcf90
2 changed files with 13 additions and 60 deletions
|
|
@ -75,11 +75,18 @@ func CreateTUN(ifname string) (TUNDevice, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
err = wt.SetInterfaceName(ifname)
|
||||
if err != nil {
|
||||
wt.DeleteInterface(0)
|
||||
return nil, errors.New("Setting interface name failed: " + err.Error())
|
||||
}
|
||||
go func() {
|
||||
retries := retryTimeout * retryRate
|
||||
for {
|
||||
err := wt.SetInterfaceName(ifname)
|
||||
if err != nil && retries > 0 {
|
||||
time.Sleep(time.Second / retryRate)
|
||||
retries--
|
||||
continue
|
||||
}
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
err = wt.FlushInterface()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue