mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-11-05 18:44:06 +08:00
update 2026-06-15 17:57:28
This commit is contained in:
1 parent
bb3d20a117
commit
18e09e96e5
4 files changed
+48
-30
No files matched your search
+15
-6
@@ -49,17 +49,26 @@ cleanup_netns() {
|
||||
hijack_resolv_conf() {
|
||||
grep -q ' /tmp/resolv\.conf ' /proc/mounts && return 0
|
||||
|
||||
cat /dev/null > "$RESOLV_DAE"
|
||||
grep -E '^(search|domain) ' /tmp/resolv.conf > "$RESOLV_DAE" 2>/dev/null
|
||||
|
||||
if [ -f "/tmp/resolv.conf.d/resolv.conf.auto" ]; then
|
||||
grep '^nameserver' "/tmp/resolv.conf.d/resolv.conf.auto" >> "$RESOLV_DAE"
|
||||
local dns_list LOGICAL_WAN
|
||||
. /lib/functions/network.sh
|
||||
network_find_wan LOGICAL_WAN 2>/dev/null
|
||||
if [ -n "$LOGICAL_WAN" ]; then
|
||||
dns_list=$(ubus call "network.interface.$LOGICAL_WAN" status 2>/dev/null | \
|
||||
jsonfilter -e '@["dns-server"][*]' 2>/dev/null)
|
||||
fi
|
||||
|
||||
if [ ! -s "$RESOLV_DAE" ]; then
|
||||
echo "nameserver 223.5.5.5" > "$RESOLV_DAE"
|
||||
echo "nameserver 119.29.29.29" >> "$RESOLV_DAE"
|
||||
if [ -z "$dns_list" ] && [ -f "/tmp/resolv.conf.d/resolv.conf.auto" ]; then
|
||||
dns_list=$(awk '/^nameserver/{print $2}' "/tmp/resolv.conf.d/resolv.conf.auto")
|
||||
fi
|
||||
|
||||
[ -z "$dns_list" ] && dns_list="119.29.29.29 223.5.5.5"
|
||||
|
||||
for dns in $dns_list; do
|
||||
echo "nameserver $dns" >> "$RESOLV_DAE"
|
||||
done
|
||||
|
||||
mount --bind "$RESOLV_DAE" /tmp/resolv.conf
|
||||
mount -o remount,ro,bind /tmp/resolv.conf
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user