Skip to content

Commit

Permalink
net: filter disabled interfaces as nameservers on Windows
Browse files Browse the repository at this point in the history
Currently the code add nameservers from all network interfaces to the nameservers list. But nameservers on disabled interfaces are not accessible and should not be considered as a nameserver candidate.

Fixes golang#56160
  • Loading branch information
zhzy0077 committed Oct 11, 2022
1 parent 0160412 commit 0a0c9b3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/net/dnsconfig_windows.go
Expand Up @@ -30,6 +30,10 @@ func dnsReadConfig(ignoredFilename string) (conf *dnsConfig) {
// 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 == 0x01 {
continue
}
sa, err := dns.Address.Sockaddr.Sockaddr()
if err != nil {
continue
Expand Down

0 comments on commit 0a0c9b3

Please sign in to comment.