gomobile-ipfs
gomobile-ipfs copied to clipboard
[gomobile-lib] implement a cleaner workaround for DNS resolver
DNS Lookup does not work by default with gomobile on Android and iOS (only on physical device). We needed to find a workaround until this golang issue is fixed.
At the moment we are using this method which is very hacky.
We could instead:
- Define a go interface containing a LookupTXT method
- Implement it in Java (using DnsResolver) and Swift (using DNSServiceQueryRecord)
- Find a clean way to override the default go-ipfs DNSResolver
Find a clean way to override the default go-ipfs DNSResolver
@Stebalien What do you think would be the best approach to do that? If we could simply implement a DNSResolver interface and have a way to override it, it could be cleaner that implementing the Namesys interface and duplicate all the original code for the sole purpose of overriding the LookupTXT method.
cc @steeve
You can enable CGo and let it use the CGo resolver instead. Since CGo is needed anyway when doing gomobile bind
it's not really any different build wise.
I thought that gomobile bind
did it but you can try to add CGO_ENABLED=1
to the env or disable the build tag netgo
.
We've been running with it since day 1, and to us it has never been an issue. There were some quirks with respect to DNS resolution on iOS (stuck resolver on weird network conditions), but I'm not sure they are still there.
Fixed by #130 using this workaround: https://github.com/ipfs-shipyard/gomobile-ipfs/pull/130/commits/86863cfce316360ffab477e54ec9b29b266ca82a#diff-04399ac2eacd4034b3100cde433ad52c1eb223ed9dfb73545c869f92ce812b0fR39-R50