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

Fix android DNS issues by using Go's built-in DNS resolver #196

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

thehxdev
Copy link

On android devices (with termux) warp-plus fails to resolve the hostname in wireguard config file. By using a custom resolver and Go's built-in DNS resolver this bug have been fixed.

command:

./warp-plus --wgconf wg.conf --bind '127.0.0.1:10808' --cache-dir $PWD

@Lanius-collaris
Copy link

Building an elf file for android need two additional environment variables, CGO_ENABLED=1 and CC=/path/to/ndk/clang.
I think it can be fixed by editing .github/workflows/go-build.yaml.

GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
GOMIPS: ${{ matrix.gomips }}
CGO_ENABLED: 0

@thehxdev
Copy link
Author

Building warp-plus for android devices with arm64 architecture does not require CGO. And the bug is not related to CGO. The problem is warp-plus could not resolve endpoint hostname in Wireguard config file because it uses net.DefaultResolver to resolve hostname to IP address.

@Lanius-collaris
Copy link

If the elf is not linked with bionic libc, it will attempt to read /etc/resolv.conf ( doesn't exist on android ) to find DNS servers, then fall back to [::1]:53 and 127.0.0.1:53.
@thehxdev

@thehxdev
Copy link
Author

Yes that's the actual problem. But using Go's built-in DNS reaolver is a simple solution that solves the problem and does not need external C libraries. Also, the executable will be fully static and other users can build warp-plus for android arm64 without C dependencies.

@bepass-org bepass-org deleted a comment Jul 30, 2024
@markpash
Copy link
Member

This is interesting, I didn't know that Go was unable to resolve names on termux. I'm not a user of termux so these bugs always seem to exist.
I have plans for DNS in the future which will hopefully improve this situation, and your fix is good for that, so I'm happy to merge this.
Can you please squash your second commit into the first and then I'll happily merge this. ❤️

Signed-off-by: thehxdev <hossein.khosravi.ce@gmail.com>
@thehxdev
Copy link
Author

thehxdev commented Jul 30, 2024

Thank you Mark! Is that ok now?

@markpash markpash merged commit c805ea8 into bepass-org:master Jul 30, 2024
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

Successfully merging this pull request may close these issues.

3 participants