luci-app-mosdns: local_dns: apply WAN interface all dns addresses
This commit is contained in:
parent
ea0d472cac
commit
e4f5269e68
@ -31,6 +31,7 @@ inital_conf() {
|
||||
}
|
||||
|
||||
init_yaml() {
|
||||
tmpdir=$(mktemp -d) || exit 1
|
||||
log_level=$(uci -q get mosdns.mosdns.log_level)
|
||||
log_file=$(uci -q get mosdns.mosdns.logfile)
|
||||
listen_port=$(uci -q get mosdns.mosdns.listen_port)
|
||||
@ -38,8 +39,7 @@ init_yaml() {
|
||||
cache_survival_time=$(uci -q get mosdns.mosdns.cache_survival_time)
|
||||
minimal_ttl_custom=$(uci -q get mosdns.mosdns.minimal_ttl)
|
||||
maximum_ttl_custom=$(uci -q get mosdns.mosdns.maximum_ttl)
|
||||
local_dns1=$(/usr/share/mosdns/mosdns.sh dns 0)
|
||||
local_dns2=$(/usr/share/mosdns/mosdns.sh dns 1)
|
||||
local_dns=$(/usr/share/mosdns/mosdns.sh dns | xargs -n1 echo " - addr:")
|
||||
remote_dns1=$(uci -q get mosdns.mosdns.remote_dns1)
|
||||
remote_dns2=$(uci -q get mosdns.mosdns.remote_dns2)
|
||||
adblock=$(/usr/share/mosdns/mosdns.sh ad)
|
||||
@ -51,10 +51,13 @@ init_yaml() {
|
||||
s,cache_survival_time,$cache_survival_time,g; \
|
||||
s,minimal_ttl_custom,$minimal_ttl_custom,g; \
|
||||
s,maximum_ttl_custom,$maximum_ttl_custom,g; \
|
||||
s,local_dns1,$local_dns1,g;s,local_dns2,$local_dns2,g; \
|
||||
s,remote_dns1,$remote_dns1,g;s,remote_dns2,$remote_dns2,g; \
|
||||
s,adblock,$adblock,g;s,remote_dns_pipeline,$enable_pipeline,g" \
|
||||
/usr/share/mosdns/default.yaml > $(uci -q get mosdns.mosdns.configfile)
|
||||
echo "${local_dns}" > $tmpdir/local_dns.txt
|
||||
sed -i -e '/- addr: local_dns/{r '$tmpdir/local_dns.txt -e';d}' \
|
||||
$(uci -q get mosdns.mosdns.configfile)
|
||||
rm -rf $tmpdir
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
|
@ -54,8 +54,7 @@ plugins:
|
||||
type: fast_forward
|
||||
args:
|
||||
upstream:
|
||||
- addr: local_dns1
|
||||
- addr: local_dns2
|
||||
- addr: local_dns
|
||||
|
||||
- tag: "forward_remote"
|
||||
type: fast_forward
|
||||
|
@ -13,12 +13,14 @@ logfile_path() (
|
||||
interface_dns() (
|
||||
peerdns=$(uci -q get network.wan.peerdns)
|
||||
proto=$(uci -q get network.wan.proto)
|
||||
if [ "$peerdns" -eq 0 ] || [ "$proto" = "static" ]; then
|
||||
ubus call network.interface.wan status | jsonfilter -e "@['dns-server'][$1]"
|
||||
if [ "$peerdns" = 0 ] || [ "$proto" = "static" ]; then
|
||||
uci -q get network.wan.dns
|
||||
else
|
||||
ubus call network.interface.wan status | jsonfilter -e "@['inactive']['dns-server'][$1]"
|
||||
interface_status=$(ubus call network.interface.wan status)
|
||||
echo $interface_status | jsonfilter -e "@['dns-server'][0]"
|
||||
echo $interface_status | jsonfilter -e "@['dns-server'][1]"
|
||||
fi
|
||||
[ $? -ne 0 ] && echo 119.29.29.29
|
||||
[ $? -ne 0 ] && echo "119.29.29.29"
|
||||
)
|
||||
|
||||
ad_block() (
|
||||
@ -50,8 +52,7 @@ geodat_update() (
|
||||
)
|
||||
|
||||
if [ "$1" == "dns" ]; then
|
||||
[ -z $2 ] && exit 0
|
||||
interface_dns $2
|
||||
interface_dns
|
||||
elif [ "$1" == "ad" ]; then
|
||||
ad_block
|
||||
elif [ "$1" == "geodata" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user