5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-23 03:11:35 +00:00

add some artifical delay to windows netsh commands, since it seems like maybe they don't take effect immediately, and this was leading to races when setting MTU

This commit is contained in:
Arceliar 2019-09-01 13:20:48 -05:00
parent c53831696b
commit 8d2c31d39c

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"os/exec" "os/exec"
"strings" "strings"
"time"
water "github.com/yggdrasil-network/water" water "github.com/yggdrasil-network/water"
) )
@ -42,6 +43,7 @@ func (tun *TunAdapter) setup(ifname string, iftapmode bool, addr string, mtu int
tun.log.Traceln(string(output)) tun.log.Traceln(string(output))
return err return err
} }
time.Sleep(time.Second) // FIXME artifical delay to give netsh time to take effect
// Bring the interface back up // Bring the interface back up
cmd = exec.Command("netsh", "interface", "set", "interface", iface.Name(), "admin=ENABLED") cmd = exec.Command("netsh", "interface", "set", "interface", iface.Name(), "admin=ENABLED")
tun.log.Debugln("netsh command:", strings.Join(cmd.Args, " ")) tun.log.Debugln("netsh command:", strings.Join(cmd.Args, " "))
@ -51,6 +53,7 @@ func (tun *TunAdapter) setup(ifname string, iftapmode bool, addr string, mtu int
tun.log.Traceln(string(output)) tun.log.Traceln(string(output))
return err return err
} }
time.Sleep(time.Second) // FIXME artifical delay to give netsh time to take effect
// Get a new iface // Get a new iface
iface, err = water.New(config) iface, err = water.New(config)
if err != nil { if err != nil {
@ -86,6 +89,7 @@ func (tun *TunAdapter) setupMTU(mtu int) error {
tun.log.Traceln(string(output)) tun.log.Traceln(string(output))
return err return err
} }
time.Sleep(time.Second) // FIXME artifical delay to give netsh time to take effect
return nil return nil
} }
@ -106,5 +110,6 @@ func (tun *TunAdapter) setupAddress(addr string) error {
tun.log.Traceln(string(output)) tun.log.Traceln(string(output))
return err return err
} }
time.Sleep(time.Second) // FIXME artifical delay to give netsh time to take effect
return nil return nil
} }