gomobile-ipfs icon indicating copy to clipboard operation
gomobile-ipfs copied to clipboard

[gomobile-lib] implement a cleaner workaround for DNS resolver

Open aeddi opened this issue 4 years ago • 3 comments

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:

aeddi avatar Jan 21 '20 16:01 aeddi

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.

gfanton avatar Jan 21 '20 17:01 gfanton

cc @steeve

moul avatar Jan 29 '20 12:01 moul

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.

steeve avatar Jan 29 '20 14:01 steeve

Fixed by #130 using this workaround: https://github.com/ipfs-shipyard/gomobile-ipfs/pull/130/commits/86863cfce316360ffab477e54ec9b29b266ca82a#diff-04399ac2eacd4034b3100cde433ad52c1eb223ed9dfb73545c869f92ce812b0fR39-R50

aeddi avatar Sep 27 '22 13:09 aeddi