Syncthing v0.12.0-rc1-c6

Heres a patch to fix dns for go 1.5 on GOOS=linux builds running on android without cgo. as go1.5 now supports pure go dns resolve by reading /etc/resolv.conf but as android doesnt have that we can pull the dns servers from the system properties. its ugly but imo better than hard coding ips.

https://github.com/OpenSilk/SyncthingAndroid/blob/master/patches/golang/netgohacks/0001-dnsconfig-hack-for-android.patch

I though that their libc resolver already deals with this, so no hacks are necessery, you just have to build it the right way?

yes, cgo enabled builds for android do work perfectly, but its arm only, so x86 still has to be built for linux, and requires the hack.

I was under the assumption that it would link with libc resolver regardless if its cgo or not cgo.

I am still surprised GOOS=android does not solve it for 1.5 out of the box.

Edit: i missed the “if netgo” right above that line but, it doesnt change anything as hostLookupFilesDNS doesnt work on android unless you use that patch i posted above. So by default netgo goos=android will not have dns resolve, even though go 1.5 is capable of dns resolve without cgo enabled

this seems to be why android dns resolve doesnt work without cgo enabled

And that’s exactly why GOOS=android should work, regardless if its arm or x86.

Edit:

So netGo by default is false, it’s only there if -tags netgo is specified, hence I still think it should work using GOOS=android without any build tags. You can probably specify -tags netcgo to even be more sure.

You can try: GODEBUG="netdns=cgo+2" GOOS=android go build

That will print which resolver its using.