summaryrefslogtreecommitdiffhomepage
path: root/tun/tun_windows.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-03-22 15:57:23 +0100
committerSimon Rozman <simon@rozman.si>2019-03-22 16:36:30 +0100
commit2faf2dcf908f96fccbfacc8e74b68c2cc4a929c7 (patch)
tree349544787503fe550f5c8cd4f6fa11af32fefb67 /tun/tun_windows.go
parent41c30a72791999aac8973b82224d3d4b9162dd51 (diff)
tun: windows: Make adapter rename asynchronous
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'tun/tun_windows.go')
-rw-r--r--tun/tun_windows.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go
index 4223190..2d8364d 100644
--- a/tun/tun_windows.go
+++ b/tun/tun_windows.go
@@ -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 {