banip: update 0.7.5-3 15168/head
authorDirk Brenken <dev@brenken.org>
Fri, 19 Mar 2021 19:49:59 +0000 (20:49 +0100)
committerDirk Brenken <dev@brenken.org>
Fri, 19 Mar 2021 19:49:59 +0000 (20:49 +0100)
* fix iptables/chain creation in setups without IPv6 support

Signed-off-by: Dirk Brenken <dev@brenken.org>
net/banip/Makefile
net/banip/files/banip.sh

index 8540356c51534ac650b3a7c5f7331cd5eb176fd9..3a3427c92174b62616ff6cec8929485c6eedfc4b 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=banip
 PKG_VERSION:=0.7.5
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index 258b16e8738a0bfdad968100ceffe8c107d4dcb3..17a25a24af248e01cdcd6df6da8c291f11acb50a 100755 (executable)
@@ -678,61 +678,65 @@ f_ipset()
                "initial")
                        for proto in "4" "6"
                        do
-                               if [ "${proto}" = "4" ]
+                               if [ "${proto}" = "4" ] && [ "${ban_proto4_enabled}" = "1" ]
                                then
                                        ipt_cmd="${ban_ipt4_cmd}"
                                        chainsets="${ban_lan_inputchains_4} ${ban_lan_forwardchains_4} ${ban_wan_inputchains_4} ${ban_wan_forwardchains_4}"
-                               elif [ "${proto}" = "6" ]
+                               elif [ "${proto}" = "6" ] && [ "${ban_proto6_enabled}" = "1" ]
                                then
                                        ipt_cmd="${ban_ipt6_cmd}"
                                        chainsets="${ban_lan_inputchains_6} ${ban_lan_forwardchains_6} ${ban_wan_inputchains_6} ${ban_wan_forwardchains_6}"
                                fi
 
-                               if [ -z "$("${ipt_cmd}" "${timeout}" -nL "${ban_chain}" 2>/dev/null)" ]
+                               if { [ "${proto}" = "4" ] && [ "${ban_proto4_enabled}" = "1" ]; } || \
+                                       { [ "${proto}" = "6" ] && [ "${ban_proto6_enabled}" = "1" ]; }
                                then
-                                       "${ipt_cmd}" "${timeout}" -N "${ban_chain}" 2>/dev/null
-                                       out_rc="${?}"
-                                       f_log "debug" "f_ipset ::: name: ${src_name:-"-"}, mode: ${mode:-"-"}, chain: ${ban_chain:-"-"}, out_rc: ${out_rc}"
-                               else
-                                       out_rc=0
-                                       for chain in ${chainsets}
-                                       do
-                                               f_iptrule "-D" "${chain}" "-j ${ban_chain}"
-                                       done
-                               fi
+                                       if [ -z "$("${ipt_cmd}" "${timeout}" -nL "${ban_chain}" 2>/dev/null)" ]
+                                       then
+                                               "${ipt_cmd}" "${timeout}" -N "${ban_chain}" 2>/dev/null
+                                               out_rc="${?}"
+                                               f_log "debug" "f_ipset ::: name: ${src_name:-"-"}, mode: ${mode:-"-"}, chain: ${ban_chain:-"-"}, out_rc: ${out_rc}"
+                                       else
+                                               out_rc=0
+                                               for chain in ${chainsets}
+                                               do
+                                                       f_iptrule "-D" "${chain}" "-j ${ban_chain}"
+                                               done
+                                       fi
 
-                               if [ "${ban_logsrc_enabled}" = "1" ] && [ "${out_rc}" = "0" ] && [ -z "$("${ipt_cmd}" "${timeout}" -nL "${ban_logchain_src}" 2>/dev/null)" ]
-                               then
-                                       "${ipt_cmd}" "${timeout}" -N "${ban_logchain_src}" 2>/dev/null
-                                       out_rc="${?}"
-                                       if [ "${out_rc}" = "0" ]
+                                       if [ "${ban_logsrc_enabled}" = "1" ] && [ "${out_rc}" = "0" ] && [ -z "$("${ipt_cmd}" "${timeout}" -nL "${ban_logchain_src}" 2>/dev/null)" ]
                                        then
-                                               "${ipt_cmd}" "${timeout}" -A "${ban_logchain_src}" -j LOG ${ban_logopts_src} --log-prefix "${ban_logprefix_src}"
+                                               "${ipt_cmd}" "${timeout}" -N "${ban_logchain_src}" 2>/dev/null
                                                out_rc="${?}"
                                                if [ "${out_rc}" = "0" ]
                                                then
-                                                       "${ipt_cmd}" "${timeout}" -A "${ban_logchain_src}" -j "${ban_logtarget_src}"
+                                                       "${ipt_cmd}" "${timeout}" -A "${ban_logchain_src}" -j LOG ${ban_logopts_src} --log-prefix "${ban_logprefix_src}"
                                                        out_rc="${?}"
+                                                       if [ "${out_rc}" = "0" ]
+                                                       then
+                                                               "${ipt_cmd}" "${timeout}" -A "${ban_logchain_src}" -j "${ban_logtarget_src}"
+                                                               out_rc="${?}"
+                                                       fi
                                                fi
+                                               f_log "debug" "f_ipset ::: name: ${src_name:-"-"}, mode: ${mode:-"-"}, logchain_src: ${ban_logchain_src:-"-"}, out_rc: ${out_rc}"
                                        fi
-                                       f_log "debug" "f_ipset ::: name: ${src_name:-"-"}, mode: ${mode:-"-"}, logchain_src: ${ban_logchain_src:-"-"}, out_rc: ${out_rc}"
-                               fi
 
-                               if [ "${ban_logdst_enabled}" = "1" ] && [ "${out_rc}" = "0" ] && [ -z "$("${ipt_cmd}" "${timeout}" -nL "${ban_logchain_dst}" 2>/dev/null)" ]
-                               then
-                                       "${ipt_cmd}" "${timeout}" -N "${ban_logchain_dst}" 2>/dev/null
-                                       out_rc="${?}"
-                                       if [ "${out_rc}" = "0" ]
+                                       if [ "${ban_logdst_enabled}" = "1" ] && [ "${out_rc}" = "0" ] && [ -z "$("${ipt_cmd}" "${timeout}" -nL "${ban_logchain_dst}" 2>/dev/null)" ]
                                        then
-                                               "${ipt_cmd}" "${timeout}" -A "${ban_logchain_dst}" -j LOG ${ban_logopts_dst} --log-prefix "${ban_logprefix_dst}"
+                                               "${ipt_cmd}" "${timeout}" -N "${ban_logchain_dst}" 2>/dev/null
                                                out_rc="${?}"
                                                if [ "${out_rc}" = "0" ]
                                                then
-                                                       "${ipt_cmd}" "${timeout}" -A "${ban_logchain_dst}" -j "${ban_logtarget_dst}"
+                                                       "${ipt_cmd}" "${timeout}" -A "${ban_logchain_dst}" -j LOG ${ban_logopts_dst} --log-prefix "${ban_logprefix_dst}"
                                                        out_rc="${?}"
+                                                       if [ "${out_rc}" = "0" ]
+                                                       then
+                                                               "${ipt_cmd}" "${timeout}" -A "${ban_logchain_dst}" -j "${ban_logtarget_dst}"
+                                                               out_rc="${?}"
+                                                       fi
                                                fi
+                                               f_log "debug" "f_ipset ::: name: initial, mode: ${mode:-"-"}, logchain_dst: ${ban_logchain_dst:-"-"}, out_rc: ${out_rc}"
                                        fi
-                                       f_log "debug" "f_ipset ::: name: initial, mode: ${mode:-"-"}, logchain_dst: ${ban_logchain_dst:-"-"}, out_rc: ${out_rc}"
                                fi
                        done
                        out_rc="${out_rc:-"${in_rc}"}"