X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/58a312461e35ace79bbb0a3b3e21215c389ee177..4ccd13ebfa22d9ae1dee2091ee780147088d6eec:/package/firewall/files/uci_firewall.sh diff --git a/package/firewall/files/uci_firewall.sh b/package/firewall/files/uci_firewall.sh index 207dcd8df..8d7538201 100755 --- a/package/firewall/files/uci_firewall.sh +++ b/package/firewall/files/uci_firewall.sh @@ -294,8 +294,11 @@ fw_rule() { [ -n "$src" -a -z "$dest" ] && ZONE=zone_$src [ -n "$src" -a -n "$dest" ] && ZONE=zone_${src}_forward [ -n "$dest" ] && TARGET=zone_${dest}_$target + + eval 'RULE_COUNT=$((++RULE_COUNT_'$ZONE'))' + add_rule() { - $IPTABLES -A $ZONE \ + $IPTABLES -I $ZONE $RULE_COUNT \ ${proto:+-p $proto} \ ${icmp_type:+--icmp-type $icmp_type} \ ${src_ip:+-s $src_ip} \ @@ -355,18 +358,18 @@ fw_redirect() { src_port_first=${src_port%-*} src_port_last=${src_port#*-} - [ "$src_port_first" -ne "$src_port_last" ] && { \ + [ "$src_port_first" != "$src_port_last" ] && { \ src_port="$src_port_first:$src_port_last"; } src_dport_first=${src_dport%-*} src_dport_last=${src_dport#*-} - [ "$src_dport_first" -ne "$src_dport_last" ] && { \ + [ "$src_dport_first" != "$src_dport_last" ] && { \ src_dport="$src_dport_first:$src_dport_last"; } dest_port2=${dest_port:-$src_dport} dest_port_first=${dest_port2%-*} dest_port_last=${dest_port2#*-} - [ "$dest_port_first" -ne "$dest_port_last" ] && { \ + [ "$dest_port_first" != "$dest_port_last" ] && { \ dest_port2="$dest_port_first:$dest_port_last"; } add_rule() {