diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-01-17 13:55:53 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-01-17 13:59:48 +0100 |
commit | b75cc38c60e36e1117bb40fd4ac78c44f1aae1f6 (patch) | |
tree | 5c3e197966b91ab8fcaf6f3c765f80938493906e | |
parent | global: bump date (diff) | |
download | wireguard-windows-b75cc38c60e36e1117bb40fd4ac78c44f1aae1f6.tar.xz wireguard-windows-b75cc38c60e36e1117bb40fd4ac78c44f1aae1f6.zip |
conf: do not examine connectivity state at boot
It turns out that checking for internet connectivity is not really a
reliable way of knowing whether the WSAHOST_NOT_FOUND is legitimate or
not. So just give up on that approach, assume WSAHOST_NOT_FOUND is
always illegitimate at boot, and loop for a long time. This might induce
annoyances for admins who want to kill legitimate WSAHOST_NOT_FOUND
services that keep trying again, but they'll just have to wait for two
minutes.
Reported-by: Simon Rozman <simon@rozman.si>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | conf/dnsresolver_windows.go | 11 | ||||
-rw-r--r-- | conf/mksyscall.go | 8 | ||||
-rw-r--r-- | conf/zsyscall_windows.go | 50 |
3 files changed, 4 insertions, 65 deletions
diff --git a/conf/dnsresolver_windows.go b/conf/dnsresolver_windows.go index cad828a3..a299c475 100644 --- a/conf/dnsresolver_windows.go +++ b/conf/dnsresolver_windows.go @@ -17,12 +17,10 @@ import ( "golang.zx2c4.com/wireguard/windows/services" ) -//sys internetGetConnectedState(flags *uint32, reserved uint32) (connected bool) = wininet.InternetGetConnectedState - func resolveHostname(name string) (resolvedIPString string, err error) { maxTries := 10 if services.StartedAtBoot() { - maxTries *= 4 + maxTries *= 3 } for i := 0; i < maxTries; i++ { if i > 0 { @@ -33,12 +31,11 @@ func resolveHostname(name string) (resolvedIPString string, err error) { return } if err == windows.WSATRY_AGAIN { - log.Printf("Temporary DNS error when resolving %s, sleeping for 4 seconds", name) + log.Printf("Temporary DNS error when resolving %s, so sleeping for 4 seconds", name) continue } - var state uint32 - if err == windows.WSAHOST_NOT_FOUND && services.StartedAtBoot() && !internetGetConnectedState(&state, 0) { - log.Printf("Host not found when resolving %s, but no Internet connection available, sleeping for 4 seconds", name) + if err == windows.WSAHOST_NOT_FOUND && services.StartedAtBoot() { + log.Printf("Host not found when resolving %s at boot time, so sleeping for 4 seconds", name) continue } return diff --git a/conf/mksyscall.go b/conf/mksyscall.go deleted file mode 100644 index 2d5d1de4..00000000 --- a/conf/mksyscall.go +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-License-Identifier: MIT - * - * Copyright (C) 2019-2022 WireGuard LLC. All Rights Reserved. - */ - -package conf - -//go:generate go run golang.org/x/sys/windows/mkwinsyscall -output zsyscall_windows.go dnsresolver_windows.go migration_windows.go storewatcher_windows.go diff --git a/conf/zsyscall_windows.go b/conf/zsyscall_windows.go deleted file mode 100644 index 783411f6..00000000 --- a/conf/zsyscall_windows.go +++ /dev/null @@ -1,50 +0,0 @@ -// Code generated by 'go generate'; DO NOT EDIT. - -package conf - -import ( - "syscall" - "unsafe" - - "golang.org/x/sys/windows" -) - -var _ unsafe.Pointer - -// Do the interface allocations only once for common -// Errno values. -const ( - errnoERROR_IO_PENDING = 997 -) - -var ( - errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) - errERROR_EINVAL error = syscall.EINVAL -) - -// errnoErr returns common boxed Errno values, to prevent -// allocations at runtime. -func errnoErr(e syscall.Errno) error { - switch e { - case 0: - return errERROR_EINVAL - case errnoERROR_IO_PENDING: - return errERROR_IO_PENDING - } - // TODO: add more here, after collecting data on the common - // error values see on Windows. (perhaps when running - // all.bat?) - return e -} - -var ( - modwininet = windows.NewLazySystemDLL("wininet.dll") - - procInternetGetConnectedState = modwininet.NewProc("InternetGetConnectedState") -) - -func internetGetConnectedState(flags *uint32, reserved uint32) (connected bool) { - r0, _, _ := syscall.Syscall(procInternetGetConnectedState.Addr(), 2, uintptr(unsafe.Pointer(flags)), uintptr(reserved), 0) - connected = r0 != 0 - return -} |