Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: go resolver on Windows takes disabled interfaces' DNS nameservers #56160

Open
zhzy0077 opened this issue Oct 11, 2022 · 2 comments · May be fixed by #56161
Open

net: go resolver on Windows takes disabled interfaces' DNS nameservers #56160

zhzy0077 opened this issue Oct 11, 2022 · 2 comments · May be fixed by #56161
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Milestone

Comments

@zhzy0077
Copy link

zhzy0077 commented Oct 11, 2022

What version of Go are you using (go version)?

$ go version
go version go1.19.2 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxx\AppData\Local\go-build
set GOENV=C:\Users\xxx\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\xxx\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\xxx\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.19.2
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\xxx\Code\gosample\go.mod
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\xxx\AppData\Local\Temp\go-build106667779=/tmp/go-build -gno-record-gcc-switches

What did you do?

  1. Create a network interface like VPN or so, but do not connect to it, i.e. disable the interface.
  2. Run code below:
package main

import (
	"context"
	"fmt"
	"net"
)

func main() {
	c := context.TODO()

	r := &net.Resolver{
		PreferGo: true,
	}

	fmt.Println(r.LookupNetIP(c, "ip", "www.google.com"))
}

What did you expect to see?

Go uses the go resolver and picks the active interfaces nameserver.

What did you see instead?

Go starts with the nameserver configured at disabled network interface.

It is because the code here doesn't filter network interfaces by its operating status as per the docs

zhzy0077 added a commit to zhzy0077/go that referenced this issue Oct 11, 2022
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
@gopherbot
Copy link

gopherbot commented Oct 11, 2022

Change https://go.dev/cl/442375 mentions this issue: net: The Go DNS resolver on Windows should filter disabled interfaces

@seankhliao seankhliao added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 12, 2022
@seankhliao
Copy link
Member

seankhliao commented Oct 12, 2022

cc @ianlancetaylor @neild

@seankhliao seankhliao changed the title net: The Go resolver on Windows takes disabled interfaces' DNS nameservers net: go resolver on Windows takes disabled interfaces' DNS nameservers Nov 1, 2022
@seankhliao seankhliao added this to the Unplanned milestone Nov 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants