Skip to content

Commit

Permalink
net: always use cgo for DNS on Android
Browse files Browse the repository at this point in the history
Android has (had?) its own local DNS resolver daemon, also my fault:

https://android.googlesource.com/platform/system/netd/+/007e987fee7e815e0c4bc820f434a632b7a69a9d

And you access that via libc, not DNS.

Fixes #10714

Change-Id: Iaff752872ce19bb5c7771ab048fd50e3f72cb73c
Reviewed-on: https://go-review.googlesource.com/9793
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
  • Loading branch information
bradfitz committed May 6, 2015
1 parent 6fd387b commit 7165c9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/net/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func initConfVal() {

// hostLookupOrder determines which strategy to use to resolve hostname.
func (c *conf) hostLookupOrder(hostname string) hostLookupOrder {
if c.forceCgoLookupHost || c.resolv.unknownOpt {
if c.forceCgoLookupHost || c.resolv.unknownOpt || c.goos == "android" {
return hostLookupCgo
}
if byteIndex(hostname, '\\') != -1 || byteIndex(hostname, '%') != -1 {
Expand Down
12 changes: 12 additions & 0 deletions src/net/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ func TestConfHostLookupOrder(t *testing.T) {
},
hostTests: []nssHostTest{{"google.com", hostLookupCgo}},
},
// Android should always use cgo.
{
name: "android",
c: &conf{
goos: "android",
nss: nssStr(""),
resolv: defaultResolvConf,
},
hostTests: []nssHostTest{
{"x.com", hostLookupCgo},
},
},
}
for _, tt := range tests {
for _, ht := range tt.hostTests {
Expand Down

0 comments on commit 7165c9b

Please sign in to comment.