From 0a6708f865fc6e8c89e0fe9ecf75aea4b617b7ec Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 7 May 2019 09:27:01 +0200 Subject: conf: retry DNS resoluion when no internet present Signed-off-by: Jason A. Donenfeld --- conf/zsyscall_windows.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'conf/zsyscall_windows.go') diff --git a/conf/zsyscall_windows.go b/conf/zsyscall_windows.go index 64bec1f4..d8984bef 100644 --- a/conf/zsyscall_windows.go +++ b/conf/zsyscall_windows.go @@ -37,16 +37,24 @@ func errnoErr(e syscall.Errno) error { } var ( + modwininet = windows.NewLazySystemDLL("wininet.dll") modole32 = windows.NewLazySystemDLL("ole32.dll") modshell32 = windows.NewLazySystemDLL("shell32.dll") modkernel32 = windows.NewLazySystemDLL("kernel32.dll") + procInternetGetConnectedState = modwininet.NewProc("InternetGetConnectedState") procCoTaskMemFree = modole32.NewProc("CoTaskMemFree") procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath") procFindFirstChangeNotificationW = modkernel32.NewProc("FindFirstChangeNotificationW") procFindNextChangeNotification = modkernel32.NewProc("FindNextChangeNotification") ) +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 +} + func coTaskMemFree(pointer uintptr) { syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(pointer), 0, 0) return -- cgit v1.2.3-59-g8ed1b