termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.09k stars 3k forks source link

[Bug]: resolv.conf is not available in curl and libcurl #21630

Open 1q23lyc45 opened 2 days ago

1q23lyc45 commented 2 days ago

Problem description

I changed resolv.conf, but it only works in dig and nslookup, not in curl. Let's look directly at the following:

u0_a198@localhost:~$ cat ../usr/etc/resolv.conf
nameserver 185.222.222.222
nameserver 45.11.45.11
u0_a198@localhost:~$ curl -v 1q23l.us.kg
* Host 1q23l.us.kg:80 was resolved.
* IPv6: ::
* IPv4: 124.236.16.201
*   Trying [::]:80...
* Connected to 1q23l.us.kg (::) port 80
* using HTTP/1.x
> GET / HTTP/1.1
> Host: 1q23l.us.kg
> User-Agent: curl/8.10.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 301 Moved Permanently
< Server: nginx/1.27.1
< Date: Wed, 02 Oct 2024 11:13:52 GMT
< Content-Type: text/html
< Content-Length: 169
< Connection: keep-alive
< Location: http://127.0.0.1:8080
<
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.27.1</center>
</body>
</html>
* Connection #0 to host 1q23l.us.kg left intact
u0_a198@localhost:~$ dig 1q23l.us.kg

; <<>> DiG 9.16.41 <<>> 1q23l.us.kg
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61118
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;1q23l.us.kg.                   IN      A

;; ANSWER SECTION:
1q23l.us.kg.            300     IN      A       104.21.37.233
1q23l.us.kg.            300     IN      A       172.67.214.176

;; Query time: 184 msec
;; SERVER: 185.222.222.222#53(185.222.222.222)
;; WHEN: Wed Oct 02 19:14:05 CST 2024
;; MSG SIZE  rcvd: 72

u0_a198@localhost:~$

What steps will reproduce the bug?

Just curl any domain name.

What is the expected behavior?

The DNS modified in resolv.conf must be applied to curl

System information

Termux Variables:
TERMUX_APK_RELEASE=GITHUB
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=4355
TERMUX_IS_DEBUGGABLE_BUILD=1
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main
# tur-repo (sources.list.d/tur.list)
deb https://tur.kcubeterm.com tur-packages tur tur-on-device tur-continuous tur-hacking
Updatable packages:
busybox/stable 1.36.1-2 aarch64 [upgradable from: 1.36.1-1]
liblzma/stable 5.6.3 aarch64 [upgradable from: 5.6.2]
xz-utils/stable 5.6.3 aarch64 [upgradable from: 5.6.2]
termux-tools version:
1.43.5
Android version:
10
Kernel build information:
Linux localhost 4.14.141+ #1 SMP PREEMPT Sun Mar 11 23:50:42 WEST 2020 aarch64 Android
Device manufacturer:
unknown
Device model:
Phh-Treble vanilla
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
1q23lyc45 commented 2 days ago

Maybe you can't reproduce it there, but this problem does exist. You can rename resolv.conf to resolv.conf.bak and you will find that curl can still resolve domain names, and the resolution is not 8.8.8.8 but the carrier DNS.