summaryrefslogtreecommitdiffhomepage
path: root/tun/wintun/wintun_windows.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-08-28 19:31:20 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2019-08-28 19:31:20 -0600
commite862131d3cf56a5db53722648c04051c064b22a8 (patch)
treea76f481ca18357cd5399db384ce3318646b054a8 /tun/wintun/wintun_windows.go
parentda28a3e9f3abc3e117a777452ba887090fd0ad98 (diff)
wintun: simplify rename logic
Diffstat (limited to 'tun/wintun/wintun_windows.go')
-rw-r--r--tun/wintun/wintun_windows.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go
index b558fd6..5624525 100644
--- a/tun/wintun/wintun_windows.go
+++ b/tun/wintun/wintun_windows.go
@@ -568,12 +568,8 @@ func (wintun *Wintun) InterfaceName() (string, error) {
func (wintun *Wintun) SetInterfaceName(ifname string) error {
const maxSuffix = 1000
availableIfname := ifname
-setloop:
for i := 0; ; i++ {
err := nci.SetConnectionName(&wintun.cfgInstanceID, availableIfname)
- if err == nil {
- break
- }
if err == windows.ERROR_DUP_NAME {
duplicateGuid, err2 := iphlpapi.InterfaceGUIDFromAlias(availableIfname)
if err2 == nil {
@@ -589,13 +585,16 @@ setloop:
if err2 == nil {
err = nci.SetConnectionName(&wintun.cfgInstanceID, availableIfname)
if err == nil {
- break setloop
+ break
}
}
break
}
}
}
+ if err == nil {
+ break
+ }
if i > maxSuffix || err != windows.ERROR_DUP_NAME {
return fmt.Errorf("NciSetConnectionName failed: %v", err)