]> Cypherpunks repositories - gostls13.git/commit
net: unify CNAME handling across ports
authorRuss Cox <rsc@golang.org>
Fri, 28 Oct 2022 14:57:14 +0000 (10:57 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 8 Nov 2022 14:54:25 +0000 (14:54 +0000)
commit6939659a085de15ba7e08ebe0c8864616ba21b76
tree32a243dae04df760a15880d457ae1b4a404935f7
parenta1c31d6803dac891b200b3598aa00224ab80c0bb
net: unify CNAME handling across ports

Unix and Windows differ in how they handle LookupCNAME(name).

If name exists in DNS with an A or AAAA record but no CNAME,
then on all operating systems and in the pure Go resolver,
LookupCNAME returns the name associated with the A/AAAA record
(the original name).

TestLookupCNAME has been testing this, because www.google.com
has no CNAME. I think it did at one point, but not anymore, and the
tests are still passing. Also added google.com as a test, since
top-level domains are disallowed from having CNAMEs.

If name exists in DNS with a CNAME record pointing to a record that
does not exist or that has no A or AAAA record,
then Windows has always reported the CNAME value,
but Unix-based systems and the pure Go resolver have reported
a failure instead. cname-to-txt.go4.org is an test record that is
a CNAME to a non-A/AAAA target (the target only has a TXT record).

This CL changes the Unix-based systems and the pure Go resolver
to match the Windows behavior, allowing LookupCNAME to succeed
whenever a CNAME exists.

TestLookupCNAME nows tests the new behavior by looking up
cname-to-txt.go4.org (run by bradfitz).

Fixes #50101.

Change-Id: Ieff5026c8535760e6313c7a41ebd5ff24de6d9be
Reviewed-on: https://go-review.googlesource.com/c/go/+/446179
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/internal/syscall/unix/asm_darwin.s
src/internal/syscall/unix/net_darwin.go
src/net/cgo_unix.go
src/net/cgo_unix_cgo.go
src/net/cgo_unix_cgo_res.go [new file with mode: 0644]
src/net/cgo_unix_cgo_resn.go [new file with mode: 0644]
src/net/cgo_unix_syscall.go
src/net/dnsclient_unix.go
src/net/dnsclient_unix_test.go
src/net/lookup.go
src/net/lookup_test.go