psanford / wormhole-william

End-to-end encrypted file transfer. A magic wormhole CLI and API in Go (golang).
MIT License
1.07k stars 54 forks source link

Is it compatible with Android armv8a phones? #96

Closed directentis1 closed 1 year ago

directentis1 commented 1 year ago

I tried to run that in Termux on my phone, but no luck. Is it due to the limitation of Android 10 operating system or by some other reason? Hope to get any help!

~ $ ./wormhole-william-linux-arm64 send get-pip.py
Error sending message: dial ws://relay.magic-wormhole.io:4000/v1: failed to WebSocket dial: failed to send handshak
e request: Get "http://relay.magic-wormhole.io:4000/v1": dial tcp: lookup relay.magic-wormhole.io on [::1]:53: read
 udp [::1]:47274->[::1]:53: read: connection refused
psanford commented 1 year ago

That error suggests that it couldn't resolve the dns name relay.magic-wormhole.io.

directentis1 commented 1 year ago

Yes, but your apk package works perfectly fine. I wonder,... maybe because the apk package version has fixed some bugs from the command line version? Hmm, sometimes I'm a bit lazy to be able to launch the terminal emulator instead of having to open the application and need to do other cumbersome thíng xD

psanford commented 1 year ago

It sounds like an issue with termux.

directentis1 commented 1 year ago

Doesn't look like it, I tried with adb shell and got same result...

psanford commented 1 year ago

I don't have an environment available to test this in so you'll need to take the lead here if you want this fixed.

Since it seems to be failing with DNS, the first thing to check is if there's some issue with using libc's gethostbyname. Can you try building with the build tag -tags netgo?

directentis1 commented 1 year ago

I will try to fork your repo and build it according to your instructions, but I will need to experiment a lot since I do not have any experience with Go. 😂

directentis1 commented 1 year ago

Doesn't look like it, I tried with adb shell and got same result...

I'm guessing it could be by some library dependency, because it looks like your program tries to resolve IPv6 addresses but fails even though my device supports IPv6. (I guess it's because of incompatibility between working library with Stub IPv6 DNS Resolver)

The simpler workaround in this situation is perhaps we should fallback to IPv4 Resolver in case of IPv6 failure?

psanford commented 1 year ago

Hmm, so let me see if I've got this straight:

wormhole-william isn't doing anything special or weird with name resolution. We use the stdlib library to dial the rendezvous server; part of the dialing code does the name resolution automatically.

When test this locally, if I change my resolv.conf from nameserver 127.0.0.1 to nameserver ::1 and I set my local stub resolver to only listen on 127.0.0.1:53 then I get the same error you are seeing above. If I make my local stub resolver listen on ::1 then it works for either of those configurations.

I don't really know anything about dns on android but presumably it has a /etc/resolv.conf? What address is that pointed at? Is it an ipv4 or ipv6 address? What address the local stub resolver configured to listen on?

Can you reproduce the issue using dig if you use 127.0.0.1 vs ::1 as the nameserver you give dig?

directentis1 commented 1 year ago

The strange thing is that nslookup -query=AAAA and ping6 work properly, but dig -6 AAAA <domain name> will not work if I don't specify dns address at the end of command.

dig -6 AAAA google.com doesn't work, but dig -6 AAAA google.com @127.0.0.53 and dig -6 AAAA google.com @2001:4860:4860::8888 both work.

psanford commented 1 year ago

What does your /etc/resolv.conf look like?

directentis1 commented 1 year ago

What does your /etc/resolv.conf look like?

Looks like my Android doen't have this file, only Termux has it, but it located at data/data/com.termux/files/usr/etc/resolv.conf.

nameserver 8.8.8.8
nameserver 8.8.4.4
psanford commented 1 year ago

The go dns resolver (for linux binaries) looks for /etc/resolv.conf. If it doesn't find that file it sets the default name server to localhost:53: https://github.com/golang/go/blob/e335a2665f5e322a7da8baa22fe816b6ef9aaf24/src/net/dnsconfig.go#L14

This seems to be a known issue with termux documented here: https://wiki.termux.com/wiki/Differences_from_Linux

It sounds like there might be a few possible solutions:

directentis1 commented 1 year ago

Thanks for your detailed anwser.

For me, the ways one and two solved my problem already. The third way is a bit more complicated, but I can use C cross-compile Docker Container to compile binaries for android, it can be done. With the third way, it will solve the problem of more people in need.

I wonder if I can embed an optional domain name resolution server (like 8.8.8.8 or 1.1.1.1) inside the program so that it can resolve domain names regardless of configuration of the device dns resolver?

psanford commented 1 year ago

You certainly could fork wormhole-william to add custom dns resolution code. That's not a patch that we're likely to accept into the main repo though.

I think option 3 will be the best solution for anyone else who runs into this problem.