Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(arm version) DNS lookup failed: read udp: read: connection refused #126

Closed
binus opened this issue Dec 2, 2018 · 5 comments
Closed

(arm version) DNS lookup failed: read udp: read: connection refused #126

binus opened this issue Dec 2, 2018 · 5 comments

Comments

@binus
Copy link

binus commented Dec 2, 2018

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.

UTC,main.go:266, INFO ,goflyway devel
main.go:277, WARNING ,Failed to read ACL config: open chinalist.txt: no such file or directory
main.go:435, INFO ,Upstream config: cf://$$:80
main.go:308, INFO ,Global proxy enabled
main.go:415, INFO ,Client fb16884 started: you->0.0.0.0:8100->cloudflare->$$:80
main.go:411, INFO ,Web console started at 127.0.0.1:8101
acl.go:42, INFO ,ACL check result: unknown >> 7 ## I added acl.go:42 to print the debug info
acl.go:43, ERROR ,ACL check error: DNS lookup failed: lookup google.com on [::1]:53: read udp [::1]:39998->[::1]:53: read: connection refused ## this is the original acl.go:42 debug print
client.go:538, LOG ,Global - google.com:80
client.go:541, ERROR ,"Dial failed: dial, lookup $$ on [::1]:53: read udp [::1]:38258->[::1]:53: read: connection refused"
......

Is it because of the -g option or ignore_dns flag?
Thanks for any clue about this.

@binus
Copy link
Author

binus commented Dec 2, 2018

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 :(

@binus
Copy link
Author

binus commented Dec 2, 2018

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.

@binus binus closed this as completed Dec 2, 2018
@binus
Copy link
Author

binus commented Dec 3, 2018

More info:
golang/go#10714
golang/go#8877
golang/go#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

@coyove
Copy link
Owner

coyove commented Dec 4, 2018

Using cgo is okay to me, otherwise we will have to use some 3rd libs like miekg/dns

@cs8425
Copy link

cs8425 commented Mar 20, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants