]> Cypherpunks repositories - gostls13.git/commitdiff
net: always use cgo for DNS on Android
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 6 May 2015 16:32:11 +0000 (09:32 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 6 May 2015 17:00:45 +0000 (17:00 +0000)
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>

src/net/conf.go
src/net/conf_test.go

index 010131c4892b532221e3f15e6ef77c175c1f9eb2..ca7fa8708fab6cc5d80c0978ea346df340963824 100644 (file)
@@ -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 {
index 01de0de794dac9898b561b97312c67e9eec83d3e..003c615eb841a49b3a96d8920ddcd0901fbd3d29 100644 (file)
@@ -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 {