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: LookupIPAddr returns incorrect error message when using custom resolver #52428

Closed
akaroot opened this issue Apr 19, 2022 · 1 comment
Closed

Comments

@akaroot
Copy link

akaroot commented Apr 19, 2022

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

$ go version

go version go1.18.1 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
$ go env
GOARCH="amd64"
GOOS="darwin"

What did you do?

Resolving an unexisting domain via a custom DNS server returns an error message with the host DNS server address instead of custom.
When I tried to resolve the domain, that exists on my local network DNS server but doesn't exist on custom (external in my case), I got the same error. That's why I assume that go correctly uses custom DNS, but when it generates a message, it ignores configured resolver server

package main

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

func main() {
	resolver := &net.Resolver{
		PreferGo:     true,
		StrictErrors: true,
		Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
			d := net.Dialer{
				Timeout: 3 * time.Second,
			}
			return d.DialContext(ctx, "udp", "1.1.1.1:53")
		},
	}
	addrs, err := resolver.LookupIPAddr(context.Background(), "fake.domain")
	if err != nil {
		panic(err)
	}

	fmt.Println(addrs)
}

What did you expect to see?

panic: lookup manager.pls.pbank.com.ua on 1.1.1.1:53: no such host

What did you see instead?

panic: lookup manager.pls.pbank.com.ua on 192.168.1.1:53: no such host

@seankhliao
Copy link
Member

Duplicate of #43703

@seankhliao seankhliao marked this as a duplicate of #43703 Apr 19, 2022
@golang golang locked and limited conversation to collaborators Apr 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants