dnsmasq: rework network interface ignore
[openwrt/staging/jow.git] / package / network / services / dnsmasq / files / dnsmasq.init
index ec9ae84ce1022c1bd142e62201ddf31e20c4f280..c5e673029187555d1a81e8ec88fefb18b39c08d1 100755 (executable)
@@ -890,6 +890,12 @@ dnsmasq_start()
                xappend "--conf-file=${dnsmasqconffile}"
        }
 
+       config_get_bool boguspriv "$cfg" boguspriv 1
+       [ "$boguspriv" -gt 0 ] && {
+               xappend "--bogus-priv"
+               [ -r "$RFC6761FILE" ] && xappend "--conf-file=$RFC6761FILE"
+       }
+
        $PROG --version | grep -osqE "^Compile time options:.* DHCPv6( |$)" && DHCPv6CAPABLE=1 || DHCPv6CAPABLE=0
 
 
@@ -952,7 +958,25 @@ dnsmasq_start()
        config_get tftp_root "$cfg" "tftp_root"
        [ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" enable_tftp "--enable-tftp"
        append_bool "$cfg" tftp_no_fail "--tftp-no-fail"
-       append_bool "$cfg" nonwildcard "--bind-dynamic" 1
+
+       config_get bind "$cfg" "bind"
+       case "$bind" in
+               dynamic|interfaces)
+                       xappend "--bind-$bind"
+                       ;;
+               "")
+                       # for compatibility reasons
+                       append_bool "$cfg" nonwildcard "--bind-dynamic" 1
+                       ;;
+       esac
+
+       config_get dnsfilter "$cfg" "dnsfilter"
+       case "$dnsfilter" in
+               A|AAAA)
+                       xappend "--filter-$dnsfilter"
+                       ;;
+       esac
+
        append_bool "$cfg" fqdn "--dhcp-fqdn"
        append_bool "$cfg" proxydnssec "--proxy-dnssec"
        append_bool "$cfg" localservice "--local-service"
@@ -1146,11 +1170,6 @@ dnsmasq_start()
        config_foreach filter_dnsmasq mxhost dhcp_mx_add "$cfg"
        echo >> $CONFIGFILE_TMP
 
-       config_get_bool boguspriv "$cfg" boguspriv 1
-       [ "$boguspriv" -gt 0 ] && {
-               xappend "--bogus-priv"
-               [ -r "$RFC6761FILE" ] && xappend "--conf-file=$RFC6761FILE"
-       }
 
        if [ "$DNSMASQ_DHCP_VER" -gt 4 ] ; then
                # Enable RA feature for when/if it is constructed,
@@ -1234,10 +1253,11 @@ dnsmasq_stop()
 
 add_interface_trigger()
 {
-       local interface ignore
+       local interface ifname ignore
 
        config_get interface "$1" interface
        config_get_bool ignore "$1" ignore 0
+       network_get_device ifname "$interface" || ignore=0
 
        [ -n "$interface" ] && [ $ignore -eq 0 ] && procd_add_interface_trigger "interface.*" "$interface" /etc/init.d/dnsmasq reload
 }