luci-app-ssr-plus: fix resolve host when chinadns-ng is enabled

Fixes: #1007

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen 2022-12-01 00:59:57 +08:00 committed by sbwml
parent 545b213a1e
commit cc9e95eb5b

View File

@ -81,7 +81,15 @@ get_host_ip() {
fi
fi
[ -z "$ip" ] || uci_set_by_name $1 ip $ip
echo ${ip:="$(uci_get_by_name $1 ip "ERROR")"}
[ -n "$ip" ] || ip="$(uci_get_by_name $1 ip "ERROR")"
local chinadns="$(uci_get_by_type global chinadns_forward)"
if [ -n "$chinadns" ] && [ "$ip" != "$host" ]; then
grep -q "$host" "$TMP_DNSMASQ_PATH/chinadns_fixed_server.conf" 2>"/dev/null" || \
echo -e "address=/$host/$ip" >> "$TMP_DNSMASQ_PATH/chinadns_fixed_server.conf"
fi
echo $ip
}
clean_log() {
@ -186,6 +194,7 @@ start_dns() {
pdnsd_enable_flag=2
;;
esac
if [ "$run_mode" = "router" ]; then
local chinadns="$(uci_get_by_type global chinadns_forward)"
if [ -n "$chinadns" ]; then