banip: update 0.8.8-2
* 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>
This commit is contained in:
parent
a9cda91502
commit
c3084be415
|
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=banip
|
PKG_NAME:=banip
|
||||||
PKG_VERSION:=0.8.8
|
PKG_VERSION:=0.8.8
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
PKG_LICENSE:=GPL-3.0-or-later
|
PKG_LICENSE:=GPL-3.0-or-later
|
||||||
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
PKG_MAINTAINER:=Dirk Brenken <dev@brenken.org>
|
||||||
|
|
||||||
|
|
|
@ -1309,10 +1309,10 @@ f_search() {
|
||||||
local item table_sets ip proto hold cnt result_flag="/var/run/banIP.search" input="${1}"
|
local item table_sets ip proto hold cnt result_flag="/var/run/banIP.search" input="${1}"
|
||||||
|
|
||||||
if [ -n "${input}" ]; then
|
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"
|
[ -n "${ip}" ] && proto="v4"
|
||||||
if [ -z "${proto}" ]; then
|
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"
|
[ -n "${ip}" ] && proto="v6"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -1327,10 +1327,7 @@ f_search() {
|
||||||
printf " %s\n" "---"
|
printf " %s\n" "---"
|
||||||
cnt="1"
|
cnt="1"
|
||||||
for item in ${table_sets}; do
|
for item in ${table_sets}; do
|
||||||
if [ -f "${result_flag}" ]; then
|
[ -f "${result_flag}" ] && break
|
||||||
rm -f "${result_flag}"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
(
|
(
|
||||||
if "${ban_nftcmd}" get element inet banIP "${item}" "{ ${ip} }" >/dev/null 2>&1; then
|
if "${ban_nftcmd}" get element inet banIP "${item}" "{ ${ip} }" >/dev/null 2>&1; then
|
||||||
printf " %s\n" "IP found in Set '${item}'"
|
printf " %s\n" "IP found in Set '${item}'"
|
||||||
|
@ -1342,7 +1339,7 @@ f_search() {
|
||||||
cnt="$((cnt + 1))"
|
cnt="$((cnt + 1))"
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
printf " %s\n" "IP not found"
|
[ -f "${result_flag}" ] && rm -f "${result_flag}" || printf " %s\n" "IP not found"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set survey
|
# Set survey
|
||||||
|
|
|
@ -61,22 +61,17 @@ f_log "info" "start banIP download processes"
|
||||||
|
|
||||||
cnt="1"
|
cnt="1"
|
||||||
for feed in allowlist ${ban_feed} blocklist; do
|
for feed in allowlist ${ban_feed} blocklist; do
|
||||||
# local feeds
|
# local feeds (sequential processing)
|
||||||
#
|
#
|
||||||
if [ "${feed}" = "allowlist" ] || [ "${feed}" = "blocklist" ]; then
|
if [ "${feed}" = "allowlist" ] || [ "${feed}" = "blocklist" ]; then
|
||||||
for proto in 4MAC 6MAC 4 6; do
|
for proto in 4MAC 6MAC 4 6; do
|
||||||
[ "${feed}" = "blocklist" ] && wait
|
[ "${feed}" = "blocklist" ] && wait
|
||||||
(f_down "${feed}" "${proto}") &
|
f_down "${feed}" "${proto}"
|
||||||
[ "${feed}" = "blocklist" ] || { [ "${feed}" = "allowlist" ] && { [ "${proto}" = "4MAC" ] || [ "${proto}" = "6MAC" ]; }; } && wait
|
|
||||||
hold="$((cnt % ban_cores))"
|
|
||||||
[ "${hold}" = "0" ] && wait
|
|
||||||
cnt="$((cnt + 1))"
|
|
||||||
done
|
done
|
||||||
wait
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# external feeds
|
# external feeds (parallel processing on multicore hardware)
|
||||||
#
|
#
|
||||||
if ! json_select "${feed}" >/dev/null 2>&1; then
|
if ! json_select "${feed}" >/dev/null 2>&1; then
|
||||||
f_log "info" "remove unknown feed '${feed}'"
|
f_log "info" "remove unknown feed '${feed}'"
|
||||||
|
|
Loading…
Reference in New Issue