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: LookupCNAME returns 'no such host' for a target that doesn't exist, instead of the target's name #5038

Closed
Frumious opened this issue Mar 12, 2013 · 7 comments

Comments

@Frumious
Copy link

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. Set up the first two CNAMES in dns, one that points to a valid A record, and one that
points to a missing hostname.

$ host -t CNAME defined.0xkarl.com
defined.0xkarl.com is an alias for www.0xkarl.com.

$ host -t CNAME undefined.0xkarl.com
undefined.0xkarl.com is an alias for stillundefined.0xkarl.com.

$ host www.0xkarl.com
www.0xkarl.com has address 69.64.236.169
$ host stillundefined.0xkarl.com
Host stillundefined.0xkarl.com not found: 3(NXDOMAIN)

2. Compile and run http://play.golang.org/p/BLtnb_hXh9

What is the expected output?
CNAME for defined.0xkarl.com is: www.0xkarl.com.
CNAME for undefined.0xkarl.com is: stillundefined.0xkarl.com.

What do you see instead?

CNAME for defined.0xkarl.com is:www.0xkarl.com.
Error looking up undefined.0xkarl.com: lookup undefined.0xkarl.com: no such host

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

Linux 3.8.2 

Which version are you using?  (run 'go version')

go version devel +2bd4d868a758 Wed Mar 13 02:40:56 2013 +0800 linux/amd64

Please provide any additional information below.

I do expect LookupHost or LookupIP to return "no such host" in this situation,
and they do, since they resolve all the way to the end, but by calling LookupCNAME I'm
trying to get the CNAME itself, which is in DNS, so I don't want it to resolve all the
way to the end and fail, I just want the first CNAME.

If I modify lookup_unix.go to always call goLookupCNAME instead of cgoLookupCNAME, I get
the output I'd expect:

diff -r 2bd4d868a758 src/pkg/net/lookup_unix.go
--- a/src/pkg/net/lookup_unix.go        Wed Mar 13 02:40:56 2013 +0800
+++ b/src/pkg/net/lookup_unix.go        Tue Mar 12 15:43:05 2013 -0700
@@ -77,10 +77,10 @@
 }
 
 func lookupCNAME(name string) (cname string, err error) {
-       cname, err, ok := cgoLookupCNAME(name)
-       if !ok {
-               cname, err = goLookupCNAME(name)
-       }
+       //      cname, err, ok := cgoLookupCNAME(name)
+       //      if !ok {
+       cname, err = goLookupCNAME(name)
+       //      }
        return
 }

CNAME for defined.0xkarl.com is:www.0xkarl.com.
CNAME for undefined.0xkarl.com is:stillundefined.0xkarl.com.
@Frumious
Copy link
Author

Comment 1:

Also, this works correctly (it returns the CNAME stillundefined.0xkarl.com instead of
"host not found") on windows.

@eaigner
Copy link
Contributor

eaigner commented May 4, 2013

Comment 3:

I have this problem on OSX 10.8.3 with go1.1beta2
CNAME returns always "no such host", although the CNAME record is valid.

@mikioh
Copy link
Contributor

mikioh commented May 9, 2013

Comment 4:

https://golang.org/cl/9322043/

Status changed to Started.

@mikioh
Copy link
Contributor

mikioh commented May 9, 2013

Comment 5:

CL 9322043 is just for Go 1.1.1.
I don't think this issue is a critical one but please let me know when I'm wrong.

@eaigner
Copy link
Contributor

eaigner commented May 9, 2013

Comment 6:

When it's already fixed, why wait until 1.1.1 is released?

@mikioh
Copy link
Contributor

mikioh commented May 9, 2013

Comment 7:

Sorry for the inconvenience but looks like have failed to catch the go1.1 release train.
https://groups.google.com/d/msg/golang-dev/JusEYpwLo7w/4bPXLRTAqcEJ

@mikioh
Copy link
Contributor

mikioh commented Jun 8, 2013

Comment 8:

Sorry, but I'd close this issue as unfortunate.
The CL on #4 was rejected:
https://groups.google.com/d/msg/golang-dev/JQ1TIm-J0Kw/gj916TpIAyUJ
Here are the rationales:
https://groups.google.com/d/msg/golang-dev/zdNs3dj0lRE/Oo9G5-Qg4roJ
I've been searching any other good C.API for solving the issue but have got none,
unfortunately. A plan B would be using external packages that implement full DNS
features like github.com/miekg/dns, github.com/cznic/dns.

Status changed to Unfortunate.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

4 participants