diff options
Diffstat (limited to 'tun/tun_windows.go')
-rw-r--r-- | tun/tun_windows.go | 17 |
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 { |