]> Cypherpunks repositories - gostls13.git/commit
net: allow netgo to use lookup from nsswitch.conf
authorVishvananda Ishaya <vishvananda@gmail.com>
Wed, 17 Feb 2016 01:58:11 +0000 (17:58 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 4 May 2016 00:19:22 +0000 (00:19 +0000)
commit9dee7771f561cf6aee081c0af6658cc81fac3918
treeb7c2220b38fd49c4cd95d5d72fec3b1628a52f21
parent84e808043ff40992ea1e25beb58365fd8e4f2591
net: allow netgo to use lookup from nsswitch.conf

Change https://golang.org/cl/8945 allowed Go to use its own DNS resolver
instead of libc in a number of cases. The code parses nsswitch.conf and
attempts to resolve things in the same order. Unfortunately, builds with
netgo completely ignore this parsing and always search via
hostLookupFilesDNS.

This commit modifies the logic to allow binaries built with netgo to
parse nsswitch.conf and attempt to resolve using the order specified
there. If the parsing results in hostLookupCGo, it falls back to the
original hostLookupFilesDNS. Tests are also added to ensure that both
the parsing and the fallback work properly.

Fixes #14354

Change-Id: Ib079ad03d7036a4ec57f18352a15ba55d933f261
Reviewed-on: https://go-review.googlesource.com/19523
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/net/conf.go
src/net/conf_test.go