banip: update 1.5.0-5
authorDirk Brenken <dev@brenken.org>
Sun, 26 Jan 2025 18:58:03 +0000 (19:58 +0100)
committerDirk Brenken <dev@brenken.org>
Sun, 26 Jan 2025 18:58:53 +0000 (19:58 +0100)
* fix a reporting issue with multiple ports/protocols

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

index 452927c82d8dd4f14f7d77c918bc5971b6ee632b..2195c9722858a0d0f9cda9212e04c6b1d2200330 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=banip
 PKG_VERSION:=1.5.0
-PKG_RELEASE:=4
+PKG_RELEASE:=5
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index 5463d3601869f6d5d89b9542be4131a3c7e1ba3c..d9a19a35507593a669c6040cf38f5db1031cdf4c 100644 (file)
@@ -1509,18 +1509,25 @@ f_report() {
                        set_proto=""
                        set_dport=""
                        for chain in _inbound _outbound; do
-                               for expr in 0 1; do
+                               for expr in 0 1 2; do
                                        if [ "${chain}" = "_inbound" ] && [ -z "${set_cntinbound}" ]; then
                                                set_cntinbound="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[${expr}].match.right=\"@${item}\"].expr[*].counter.packets")"
                                        elif [ "${chain}" = "_outbound" ] && [ -z "${set_cntoutbound}" ]; then
                                                set_cntoutbound="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[${expr}].match.right=\"@${item}\"].expr[*].counter.packets")"
                                        fi
-                                       [ "${expr}" = "1" ] && [ -z "${set_dport}" ] && set_dport="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[${expr}].match.right=\"@${item}\"].expr[*].match.right.set")"
-                                       [ "${expr}" = "1" ] && [ -z "${set_proto}" ] && set_proto="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[${expr}].match.right=\"@${item}\"].expr[*].match.left.payload.protocol")"
+                                       [ -z "${set_proto}" ] && set_proto="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[2].match.right=\"@${item}\"].expr[0].match.right.set")"
+                                       [ -z "${set_proto}" ] && set_proto="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[1].match.right=\"@${item}\"].expr[0].match.left.payload.protocol")"
+                                       [ -z "${set_dport}" ] && set_dport="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[2].match.right=\"@${item}\"].expr[1].match.right.set")"
+                                       [ -z "${set_dport}" ] && set_dport="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[2].match.right=\"@${item}\"].expr[1].match.right")"
+                                       [ -z "${set_dport}" ] && set_dport="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[1].match.right=\"@${item}\"].expr[0].match.right.set")"
+                                       [ -z "${set_dport}" ] && set_dport="$(printf "%s" "${table_json}" | "${ban_jsoncmd}" -ql1 -e "@.nftables[@.rule.chain=\"${chain}\"][@.expr[1].match.right=\"@${item}\"].expr[0].match.right")"
                                done
                        done
                        if [ -n "${set_proto}" ] && [ -n "${set_dport}" ]; then
                                sum_setports="$((sum_setports + 1))"
+                               set_proto="${set_proto//[\{\}\":]/}"
+                               set_proto="${set_proto#\[ *}"
+                               set_proto="${set_proto%* \]}"
                                set_dport="${set_dport//[\{\}\":]/}"
                                set_dport="${set_dport#\[ *}"
                                set_dport="${set_dport%* \]}"