From 19f70f5f56d2bcb743cad4bb4df943f223dd967f Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Fri, 31 May 2019 15:04:52 +0200 Subject: tunnel: make tcp/ip waiting explicit Signed-off-by: Jason A. Donenfeld --- tunnel/ifaceconfig.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tunnel/ifaceconfig.go') 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 -- cgit v1.2.3-59-g8ed1b