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: pure Go resolver(netdns) can not resolve hostname.local #35067

Open
atlas-comstock opened this issue Oct 22, 2019 · 10 comments
Open

net: pure Go resolver(netdns) can not resolve hostname.local #35067

atlas-comstock opened this issue Oct 22, 2019 · 10 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@atlas-comstock
Copy link

atlas-comstock commented Oct 22, 2019

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

go version go1.13.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/atlas/Library/Caches/go-build"
GOENV="/Users/atlas/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/yonghao.hu/mycode/go_dir_path"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/yonghao.hu/mycode/go_dir_path/src/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wf/nw471wh91nj2j_dsrfrk4htnjtqhhw/T/go-build666420423=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

package main

import (
	"fmt"
	"net"
)

func main() {
	dialer := &net.Dialer{
		LocalAddr: nil,
	}

	_, err := dialer.Dial("tcp", "atalas-mac.local:4150")
	if err != nil {
		fmt.Println("resolve atalas-mac.local failed: ", err)
	} else {
		fmt.Println("resolve myaliashost success")
	}
	_, err = dialer.Dial("tcp", "myaliashost:4150")
	if err != nil {
		fmt.Println("resolve myaliashost failed: ", err)
	}
	fmt.Println("resolve myaliashost success")
}

Just run GODEBUG=netdns=go+4 go run test.go

What did you expect to see?

Resolve to 127.0.0.1

What did you see instead?

resolve mac.local failed: dial tcp: lookup mac.local on 10.22.12.45:53: no such host

@bradfitz bradfitz changed the title pure Go resolver(netdns) can not resolve hostname.local net: pure Go resolver(netdns) can not resolve hostname.local Oct 22, 2019
@bradfitz
Copy link
Contributor

Yes, that's known, as the docs at https://golang.org/pkg/net/#hdr-Name_Resolution imply, and we're unlikely to implement it.

If you need to resolve those names, use a different resolver.

@bradfitz bradfitz added this to the Unplanned milestone Oct 22, 2019
@atlas-comstock
Copy link
Author

atlas-comstock commented Oct 22, 2019

@bradfitz Hi, thanks for your reply . I know sth about this before writing the issue. Could u plz tell me why not to implement it ? What is the consideration?

@bradfitz
Copy link
Contributor

It's a lot of code for very few users and the system DNS resolver is usually fine. The advantage of using the pure Go resolver is usually to avoid cgo and expensive threads being tied up during resolution, but that only matters when you have, say, tens of thousands of outstanding lookups. (e.g. you're a web crawler binary) But if you have tens of thousands of mDNS lookups outstanding, you probably have bigger problems on your LAN.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 22, 2019
@alex-leonhardt

This comment was marked as off-topic.

@ianlancetaylor

This comment was marked as off-topic.

@alex-leonhardt

This comment was marked as off-topic.

@jdmarshall

This comment was marked as resolved.

@davecheney

This comment was marked as resolved.

@jdmarshall

This comment was marked as resolved.

@davecheney

This comment was marked as resolved.

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.
Projects
None yet
Development

No branches or pull requests

7 participants