diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-31 15:04:52 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-31 15:05:51 +0200 |
commit | 19f70f5f56d2bcb743cad4bb4df943f223dd967f (patch) | |
tree | d2335629778192457e433960f62b312b3f801dd5 /tunnel/ifaceconfig.go | |
parent | firewall: use random GUIDs (diff) | |
download | wireguard-windows-19f70f5f56d2bcb743cad4bb4df943f223dd967f.tar.xz wireguard-windows-19f70f5f56d2bcb743cad4bb4df943f223dd967f.zip |
tunnel: make tcp/ip waiting explicit
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | tunnel/ifaceconfig.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tunnel/ifaceconfig.go b/tunnel/ifaceconfig.go index 1ad076fa..3954441b 100644 --- a/tunnel/ifaceconfig.go +++ b/tunnel/ifaceconfig.go @@ -10,6 +10,7 @@ import ( "log" "net" "sort" + "time" "golang.org/x/sys/windows" "golang.zx2c4.com/wireguard/tun" @@ -221,3 +222,21 @@ func enableFirewall(conf *conf.Config, tun *tun.NativeTun) error { } return firewall.EnableFirewall(tun.LUID(), conf.Interface.DNS, restrictAll) } + +func waitForFamilies(tun *tun.NativeTun) { + //TODO: This whole thing is a disgusting hack that shouldn't be neccessary. + + f := func(luid winipcfg.LUID, family winipcfg.AddressFamily, maxRetries int) { + for i := 0; i < maxRetries; i++ { + _, err := luid.IPInterface(family) + if i != maxRetries-1 && err == windows.ERROR_NOT_FOUND { + time.Sleep(time.Millisecond * 50) + continue + } + break + } + } + luid := winipcfg.LUID(tun.LUID()) + f(luid, windows.AF_INET, 100) + f(luid, windows.AF_INET6, 3) +}
\ No newline at end of file |