Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net: LookupAddr changed result form in Go 1.5 #12189
Reported via email: LookupAddr("126.96.36.199") returned "google-public-dns-a.google.com." (with trailing dot) in all Go releases to date. In Go 1.5 candidate it returns "google-public-dns.a.google.com" (no trailing dot).
This was an intentional change, in CL 3420, but I believe it was a mistake. The argument made there was that the result was inconsistent depending on whether the C library resolver or the pure Go DNS resolver was being used. But Go 1.4 and earlier never used the C library resolver for this query. So the inconsistency indicated was only introduced after Go 1.4 and does not justify deviating from the Go 1.4 behavior.
I am still investigating and will post more details when I'm done, but right now it looks like we should put the dot back for consistency with all previous Go releases.
I checked all the Lookup functions. Here is a program to do that (comment out the NS code in Go 1):
Here are some Go versions running on Linux:
Compiled with plain make.bash (so cgo is enabled):
Compiled with CGO_ENABLED=0 make.bash:
It may be different on non-Linux systems, but it seems like literally every release of Go to date has had the trailing dot, while the current 1.5 tree has dropped it.
Furthermore, the dropping of the trailing dot in LookupAddr appears to be inconsistent with all the other functions, even in Go 1.5. (LookupTXT doesn't count, since it returns uninterpreted text, but I wanted to run all the Lookups.)
For both these reasons I think we should put the final dot back in.
I will prepare a CL.
This is even worse than I thought. There is no code that takes the dot out from the Go lookups. The problem is that by default, and even when you set GODEBUG=netdns=go, the code tries the new C library wrappers before trying pure Go.
So not only did the result change, but now each blocked LookupAddr takes a full thread instead of a goroutine. That behavior definitely has to be rolled back.
Same test ran on
… of local source The builtin name resolver using various resolution techniques is a bit complicated and we sometimes fotget to take care of all the go and cgo code paths and exchanging information to local and remote sources. This change makes LookupAddr return absolute domain names even in the case of local source. Updates #12189. Fixes #12240. Change-Id: Icdd3375bcddc7f5d4d3b24f134d93815073736fc Reviewed-on: https://go-review.googlesource.com/17216 Reviewed-by: Brad Fitzpatrick <firstname.lastname@example.org>
This change makes existing Lookup API test cases conform to the new return value form that all the Lookup APIs except LookupTXT must return a single or multiple absolute domain names. Updates #12189. Fixes #12193. Change-Id: I03ca09be5bff80e818fbcdc26039daa33d5440a8 Reviewed-on: https://go-review.googlesource.com/17411 Run-TryBot: Mikio Hara <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Brad Fitzpatrick <email@example.com>