banip: update 0.8.8-2
authorDirk Brenken <dev@brenken.org>
Sat, 24 Jun 2023 11:09:40 +0000 (13:09 +0200)
committerDirk Brenken <dev@brenken.org>
Sat, 24 Jun 2023 20:28:32 +0000 (22:28 +0200)
* process local lists in strict sequential order to prevent possible race conditions
* support ranges in the IP search, too
* fix some minor search issues

Signed-off-by: Dirk Brenken <dev@brenken.org>
(cherry picked from commit c3084be415f5c701a319342c85ca626996b5b463)

net/banip/Makefile
net/banip/files/banip-functions.sh
net/banip/files/banip-service.sh

index 2aa306ed431ae3d3b4c5c4f5167871740c0e1599..95dc3664155dfca4049ce2c3d76a76f3030e3d7f 100644 (file)
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=banip
 PKG_VERSION:=0.8.8
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 PKG_LICENSE:=GPL-3.0-or-later
 PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
 
index 92d8e5a2a8bd0493dc6998d78270e94e0ed93b4a..a04265f65e2c3b3bac2d364c591fad31c7358b21 100644 (file)
@@ -1309,10 +1309,10 @@ f_search() {
        local item table_sets ip proto hold cnt result_flag="/var/run/banIP.search" input="${1}"
 
        if [ -n "${input}" ]; then
-               ip="$(printf "%s" "${input}" | "${ban_awkcmd}" 'BEGIN{RS="(([0-9]{1,3}\\.){3}[0-9]{1,3})+"}{printf "%s",RT}')"
+               ip="$(printf "%s" "${input}" | "${ban_awkcmd}" 'BEGIN{RS="(([0-9]{1,3}\\.){3}(1?[0-9][0-9]?|2[0-4][0-9]|25[0-5])(\/(1?[0-9]|2?[0-9]|3?[0-2]))?[[:space:]]*$)"}{printf "%s",RT}')"
                [ -n "${ip}" ] && proto="v4"
                if [ -z "${proto}" ]; then
-                       ip="$(printf "%s" "${input}" | "${ban_awkcmd}" 'BEGIN{RS="([A-Fa-f0-9]{1,4}::?){3,7}[A-Fa-f0-9]{1,4}"}{printf "%s",RT}')"
+                       ip="$(printf "%s" "${input}" | "${ban_awkcmd}" 'BEGIN{RS="(([0-9A-f]{0,4}:){1,7}[0-9A-f]{0,4}:?(\/(1?[0-2][0-8]|[0-9][0-9]))?)([[:space:]].*|$)"}{printf "%s",RT}')"
                        [ -n "${ip}" ] && proto="v6"
                fi
        fi
@@ -1327,10 +1327,7 @@ f_search() {
        printf "    %s\n" "---"
        cnt="1"
        for item in ${table_sets}; do
-               if [ -f "${result_flag}" ]; then
-                       rm -f "${result_flag}"
-                       return
-               fi
+               [ -f "${result_flag}" ] && break
                (
                        if "${ban_nftcmd}" get element inet banIP "${item}" "{ ${ip} }" >/dev/null 2>&1; then
                                printf "    %s\n" "IP found in Set '${item}'"
@@ -1342,7 +1339,7 @@ f_search() {
                cnt="$((cnt + 1))"
        done
        wait
-       printf "    %s\n" "IP not found"
+       [ -f "${result_flag}" ] && rm -f "${result_flag}" || printf "    %s\n" "IP not found"
 }
 
 # Set survey
index 1170c8b1d5eadbb4a1d0a5b3834ea26771bbc239..47abf43cac8090aa683976a35e8c91745fbb93c7 100755 (executable)
@@ -61,22 +61,17 @@ f_log "info" "start banIP download processes"
 
 cnt="1"
 for feed in allowlist ${ban_feed} blocklist; do
-       # local feeds
+       # local feeds (sequential processing)
        #
        if [ "${feed}" = "allowlist" ] || [ "${feed}" = "blocklist" ]; then
                for proto in 4MAC 6MAC 4 6; do
                        [ "${feed}" = "blocklist" ] && wait
-                       (f_down "${feed}" "${proto}") &
-                       [ "${feed}" = "blocklist" ] || { [ "${feed}" = "allowlist" ] && { [ "${proto}" = "4MAC" ] || [ "${proto}" = "6MAC" ]; }; } && wait
-                       hold="$((cnt % ban_cores))"
-                       [ "${hold}" = "0" ] && wait
-                       cnt="$((cnt + 1))"
+                       f_down "${feed}" "${proto}"
                done
-               wait
                continue
        fi
 
-       # external feeds
+       # external feeds (parallel processing on multicore hardware)
        #
        if ! json_select "${feed}" >/dev/null 2>&1; then
                f_log "info" "remove unknown feed '${feed}'"