Closed binus closed 5 years ago
Seems at least we need to do one dns resolve locally, to resolve the upstream cloudfare domain! maybe the net.ResolveIPAddr doesn't works well in arm :(
Solved: net.ResolveIPAddr in arm may query local dns server ( [::1]:53 ), but missing. Set up manually and all goes well. BTW: thanks for your useful logg debug tool, which help me alot.
More info: https://github.com/golang/go/issues/10714 https://github.com/golang/go/issues/8877 https://github.com/golang/go/issues/24393 https://stackoverflow.com/questions/38959067/dns-lookup-issue-when-running-my-go-app-in-termux
Fix method 1: set up local dns server and listen udp:53 , need root. Fix method 2: hack go/net to dial higher udp port for dns resolve, to avoid root privilege. Fix method 3: use cgo way. Fix method 4: use pure go way but change default/fallback behavior. Fix method 5: wait for ʕ ◔ϖ◔ʔ (golang) solving this problem ...
EOF
Using cgo is okay to me, otherwise we will have to use some 3rd libs like miekg/dns
I use some hack & reflect to overwrite defaultNS
in net
package.
And just work!!
Only test with go version go1.11.5 linux/amd64
,
Build with GOOS=linux GOARCH=arm GOARM=7
and GOOS=linux GOARCH=arm64
,
On a Android 6.0, kernel 3.10.49, aarch64 CPU phone.
The code: https://gist.github.com/cs8425/107e01a0652f1f1f6e033b5b68364b5e
version fa7eda0, with ignore_local_dns ON go build arm version cmd: ./gof -up="cf://$$:80" -k="$$" -l=":8100" -web-port="8101" -lv=dbg -g -U=http firefox -> SwitchyOmega -> gof:socks5 Errror only occurs in arm version. Linux x86 and windows are all good.
Is it because of the -g option or ignore_dns flag? Thanks for any clue about this.