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: resolver fails to resolve host with 2 cnames chain or more #52005

Closed
nikitakogan1 opened this issue Mar 29, 2022 · 2 comments
Closed

net: resolver fails to resolve host with 2 cnames chain or more #52005

nikitakogan1 opened this issue Mar 29, 2022 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@nikitakogan1
Copy link

nikitakogan1 commented Mar 29, 2022

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

$ go version
**1.17.6**

Does this issue reproduce with the latest release?

Yes.

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

MacOs (darwin). but it is also reproduced in other env types.

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/i520773/Library/Caches/go-build"
GOENV="/Users/i520773/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/i520773/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/i520773/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.17.6/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.17.6/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/i520773/Desktop/repos/e2e-tests/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/39/cwqhd85n7cl0vrtf4c5kcw200000gn/T/go-build3546095244=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I am trying to resolve a dns record that is pointing to a cname. and the other cname is pointing to A record.
(I have a record which is resolved to a cname and the cname is resolved to an ip)
I am getting the error: no such host.

Code:

func issueLookUp(host string) ([]string, error) {
	ips, err := net.LookupHost(host)
	if err != nil {
		return nil, fmt.Errorf("error in lookup:\n %v", err)
	}
	if len(ips) == 0 {
		return nil, fmt.Errorf("LookupHost() empty return value")
	}
	for _, ip := range ips {
		fmt.Println("found ip ", ip)
	}
	return ips, nil
}

it is working for a url like google.com but it is failing for urls that has 2 CNAMEs in their resolving "chain".
The same code is working if we have only 1 cname in the chain.

What did you expect to see?

I expect the resolving to be successful.

What did you see instead?

lookup <some_url> on : no such host

Thanks!!

@gopherbot gopherbot added this to the pkgsite/unplanned milestone Mar 29, 2022
@seankhliao seankhliao removed this from the pkgsite/unplanned milestone Mar 29, 2022
@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed pkgsite labels Mar 29, 2022
@seankhliao seankhliao changed the title x/pkgsite: golang net resolver fails to resolve host with 2 cnames chain or more net: resolver fails to resolve host with 2 cnames chain or more Mar 29, 2022
@seankhliao
Copy link
Member

With the following records:

  • go-52005-a.liao.dev CNAME go-52005-b.liao.dev
  • go-52005-b.liao.dev CNAME go-52005-c.liao.dev
  • go-52005-c.liao.dev A 127.0.0.1

The code finds the correct host:

10:45:00 ~/tmp/testrepo-847 0:01:40
main » cat main.go                       
package main

import (
	"fmt"
	"net"
)

func main() {
	fmt.Println(issueLookUp("go-52005-a.liao.dev"))
}

func issueLookUp(host string) ([]string, error) {
	ips, err := net.LookupHost(host)
	if err != nil {
		return nil, fmt.Errorf("error in lookup:\n %v", err)
	}
	if len(ips) == 0 {
		return nil, fmt.Errorf("LookupHost() empty return value")
	}
	for _, ip := range ips {
		fmt.Println("found ip ", ip)
	}
	return ips, nil
}

10:45:19 ~/tmp/testrepo-847 0:00:00
main » go run .
found ip  127.0.0.1
[127.0.0.1] <nil>

You'll need to provided more information to reproduce the issue.

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 29, 2022
@nikitakogan1
Copy link
Author

nikitakogan1 commented Mar 30, 2022

Hi @seankhliao

Thanks for the quick reply.
My problem was that i needed to use the appropriate name server.
Closing this issue.

@golang golang locked and limited conversation to collaborators Mar 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants