stunnel / static-curl

static builds cURL with HTTP3
MIT License
198 stars 28 forks source link

dns fails on android #43

Closed binarynoise closed 9 months ago

binarynoise commented 9 months ago
gta4xlwifi /data/local/tmp # ./curl -V
curl 8.5.0 (aarch64-pc-linux-gnu) libcurl/8.5.0 quictls/3.1.4 zlib/1.3 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.4 libssh2/1.11.0 nghttp2/1.58.0 ngtcp2/1.1.0 nghttp3/1.1.0
Release-Date: 2023-12-06
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS brotli HSTS HTTP2 HTTP3 HTTPS-proxy IDN IPv6 Largefile libz NTLM SSL threadsafe TLS-SRP TrackMemory UnixSockets zstd
gta4xlwifi /data/local/tmp # ./curl -I google.com
curl: (6) Could not resolve host: google.com

gta4xlwifi /data/local/tmp # curl -V                                                        curl 7.80.0 (Android) libcurl/7.80.0 BoringSSL zlib/1.2.11
Release-Date: 2021-11-10
Protocols: file http https mqtt
Features: alt-svc AsynchDNS HSTS HTTPS-proxy IPv6 libz NTLM SSL UnixSockets
gta4xlwifi /data/local/tmp # curl -I google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Mon, 11 Dec 2023 12:44:17 GMT
Expires: Wed, 10 Jan 2024 12:44:17 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN

gta4xlwifi /data/local/tmp #

The reason could be that /etc/resolv.conf doesn't exist. ./curl is your curl, curl is the android curl (lineage os)

Adding -vs to the command doesn't print something different

travislee89 commented 9 months ago

Android programs need to be built with the Android NDK if they use some of the system APIs. I will take a look at it.

binarynoise commented 9 months ago

Oh, ok. I could also try Termux or the like if they have an already working curl where they could enable http3.

Or maybe an option for a dns fallback or general custom dns server could work

travislee89 commented 9 months ago

It seems to require a relatively large modification to be compatible with Android's DNS. There is a workaround though, I compiled in c-ares to resolve DNS without using the system API. For Android, modify $HOME/.curlrc

--dns-servers 1.1.1.1,8.8.8.8
--cacert /data/data/com.termux/files/usr/etc/tls/cert.pem

Now you can get this compiled version from the Actions of the test: https://github.com/stunnel/static-curl/actions/runs/7230001570 This change will be included in the next release.

binarynoise commented 9 months ago

Works great, thank you!