The Go DNS resolver on Windows should filter disabled
interfaces. Otherwise disabled TUN devices, VPNs will be also
considered as valid nameservers and finally timedout.
Fixes #56160
(Originally from Zhiyuan Zheng <zhzy0077@hotmail.com>
in https://go.dev/cl/442375)
Co-authored-by: Zhiyuan Zheng <zhzy0077@hotmail.com>
GitHub-Last-Rev:
db158625bb46692cbbc09e3fe4dfa023c733f4e6
GitHub-Pull-Request: golang/go#56161
Change-Id: I7becebc55c8ac612c670c533855f7e6ca397a496
Reviewed-on: https://go-review.googlesource.com/c/go/+/500375
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
package net
import (
+ "internal/syscall/windows"
"syscall"
"time"
)
// In practice, however, it mostly works.
for _, aa := range aas {
for dns := aa.FirstDnsServerAddress; dns != nil; dns = dns.Next {
+ // Only take interfaces whose OperStatus is IfOperStatusUp(0x01) into DNS configs.
+ if aa.OperStatus != windows.IfOperStatusUp {
+ continue
+ }
sa, err := dns.Address.Sockaddr.Sockaddr()
if err != nil {
continue