}
start_instance() {
- local cfg="$1" param listen_addr listen_port ipv6_resolvers_only p
+ local cfg="$1" param listen_addr listen_port ipv6_resolvers_only p url
+ config_get url "$cfg" 'resolver_url'
config_get_bool ipv6_resolvers_only "$cfg" 'use_ipv6_resolvers_only' '0'
append_parm "$cfg" 'resolver_url' '-r'
append_parm "$cfg" 'listen_addr' '-a' '127.0.0.1'
procd_set_param stderr 1
procd_set_param stdout 1
procd_set_param respawn
+ procd_open_data
+ json_add_string url "$url"
if [ "$force_dns" -ne 0 ]; then
- procd_open_data
json_add_array firewall
for p in $force_dns_port; do
if netstat -tuln | grep 'LISTEN' | grep ":${p}" >/dev/null 2>&1 || [ "$p" = '53' ]; then
fi
done
json_close_array
- procd_close_data
fi
+ procd_close_data
procd_close_instance
if [ "$?" ]; then
network_find_wan6 wan6
wan6="${wan6:-wan6}"
fi
- for i in $wan $wan6; do
- procd_add_interface_trigger "interface.*" "$i" "/etc/init.d/${packageName}" start
+ for i in "$wan" "$wan6"; do
+ [ -n "$i" ] && procd_add_interface_trigger "interface.*" "$i" "/etc/init.d/${packageName}" start
done
- procd_add_config_trigger "config.change" "$packageName" "/etc/init.d/${packageName}" start
+ procd_add_config_trigger "config.change" "$packageName" "/etc/init.d/${packageName}" reload
}
service_started() { procd_set_config_changed firewall; }
fi
uci_remove 'dhcp' "$cfg" 'doh_backup_noresolv'
fi
- if [ -n "$(uci_get 'dhcp' "$cfg" 'doh_backup_server')" ]; then
+ if uci_get 'dhcp' "$cfg" 'doh_backup_server' >/dev/null 2>&1; then
dnsmasq_doh_server "$cfg" 'remove'
for i in $(uci_get 'dhcp' "$cfg" 'doh_backup_server'); do
uci_add_list_if_new 'dhcp' "$cfg" 'server' "$i"