From ad755e0c4ddb63f8b8ed2204043ce750a4d4b928 Mon Sep 17 00:00:00 2001 From: Dirk Brenken Date: Sun, 21 Apr 2024 21:57:17 +0200 Subject: [PATCH] banip: update 0.9.5-2 * fixed possible Set search race condition (initiated from LuCI frontend) * fixed the "no result" Set search problem in LuCI * removed abandoned feeds: spamhaus edrop (was merged with spamhaus drop) Signed-off-by: Dirk Brenken --- net/banip/Makefile | 2 +- net/banip/files/banip-functions.sh | 15 +++++++++++---- net/banip/files/banip.feeds | 5 ----- net/banip/files/banip.init | 7 ++++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/net/banip/Makefile b/net/banip/Makefile index e8ba7edc19..14636f1b81 100644 --- a/net/banip/Makefile +++ b/net/banip/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=banip PKG_VERSION:=0.9.5 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=GPL-3.0-or-later PKG_MAINTAINER:=Dirk Brenken diff --git a/net/banip/files/banip-functions.sh b/net/banip/files/banip-functions.sh index 1498c8cb0a..50e805b5a4 100644 --- a/net/banip/files/banip-functions.sh +++ b/net/banip/files/banip-functions.sh @@ -1559,14 +1559,14 @@ f_search() { printf "%s\n%s\n%s\n" ":::" "::: no valid search input" ":::" return fi - printf "%s\n%s\n%s\n" ":::" "::: banIP Search" ":::" - printf " %s\n" "Looking for IP '${ip}' on $(date "+%Y-%m-%d %H:%M:%S")" - printf " %s\n" "---" cnt="1" for item in ${table_sets}; do [ -f "${result_flag}" ] && break ( if "${ban_nftcmd}" get element inet banIP "${item}" "{ ${ip} }" >/dev/null 2>&1; then + printf "%s\n%s\n%s\n" ":::" "::: banIP Search" ":::" + printf " %s\n" "Looking for IP '${ip}' on $(date "+%Y-%m-%d %H:%M:%S")" + printf " %s\n" "---" printf " %s\n" "IP found in Set '${item}'" : >"${result_flag}" fi @@ -1576,7 +1576,14 @@ f_search() { cnt="$((cnt + 1))" done wait - [ -f "${result_flag}" ] && rm -f "${result_flag}" || printf " %s\n" "IP not found" + if [ -f "${result_flag}" ]; then + rm -f "${result_flag}" + else + printf "%s\n%s\n%s\n" ":::" "::: banIP Search" ":::" + printf " %s\n" "Looking for IP '${ip}' on $(date "+%Y-%m-%d %H:%M:%S")" + printf " %s\n" "---" + printf " %s\n" "IP not found" + fi } # Set survey diff --git a/net/banip/files/banip.feeds b/net/banip/files/banip.feeds index e5f817371a..36982654ba 100644 --- a/net/banip/files/banip.feeds +++ b/net/banip/files/banip.feeds @@ -108,11 +108,6 @@ "rule_4": "/^(([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/%s,\\n\",$1,$3}", "descr": "dshield IP blocklist" }, - "edrop":{ - "url_4": "https://www.spamhaus.org/drop/edrop.txt", - "rule_4": "/^(([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,\\n\",$1}", - "descr": "spamhaus edrop compilation" - }, "etcompromised":{ "url_4": "https://iplists.firehol.org/files/et_compromised.ipset", "rule_4": "/^(([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]))?)$/{printf \"%s,\\n\",$1}", diff --git a/net/banip/files/banip.init b/net/banip/files/banip.init index 0aae3befab..2b6a526c88 100755 --- a/net/banip/files/banip.init +++ b/net/banip/files/banip.init @@ -23,10 +23,10 @@ ban_lock="/var/run/banip.lock" [ "${action}" = "boot" ] && "${ban_init}" running && exit 0 { [ "${action}" = "stop" ] || [ "${action}" = "report" ] || [ "${action}" = "search" ] || [ "${action}" = "survey" ] || [ "${action}" = "lookup" ]; } && ! "${ban_init}" running && exit 0 [ ! -r "${ban_funlib}" ] && { [ "${action}" = "boot" ] || [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "stop" ] || [ "${action}" = "report" ] || [ "${action}" = "search" ] || [ "${action}" = "survey" ] || [ "${action}" = "lookup" ] || [ "${action}" = "status" ]; } && exit 1 -[ -d "${ban_lock}" ] && { [ "${action}" = "boot" ] || [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "lookup" ]; } && exit 1 -[ ! -d "${ban_lock}" ] && { [ "${action}" = "boot" ] || [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "lookup" ]; } && mkdir -p "${ban_lock}" +[ -d "${ban_lock}" ] && { [ "${action}" = "boot" ] || [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "lookup" ] || [ "${action}" = "search" ]; } && exit 1 +[ ! -d "${ban_lock}" ] && { [ "${action}" = "boot" ] || [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "lookup" ] || [ "${action}" = "search" ]; } && mkdir -p "${ban_lock}" { [ "${action}" = "boot" ] || [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "stop" ] || [ "${action}" = "report" ] || [ "${action}" = "search" ] || [ "${action}" = "survey" ] || [ "${action}" = "lookup" ] || [ "${action}" = "status" ]; } && . "${ban_funlib}" -[ ! -d "${ban_lock}" ] && { [ "${action}" = "boot" ] || [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "lookup" ]; } && exit 1 +[ ! -d "${ban_lock}" ] && { [ "${action}" = "boot" ] || [ "${action}" = "start" ] || [ "${action}" = "restart" ] || [ "${action}" = "reload" ] || [ "${action}" = "lookup" ] || [ "${action}" = "search" ]; } && exit 1 boot() { : >"${ban_pidfile}" @@ -81,6 +81,7 @@ report() { search() { f_search "${1}" + rm -rf "${ban_lock}" } survey() {