Skip to content

Commit 7b06b1d

Browse files
committed
banip: update 0.9.4-2
* fix a long standing problem in the logfile-parser with dropbear and compressed IPv6 addresses Signed-off-by: Dirk Brenken <[email protected]>
1 parent 21c7214 commit 7b06b1d

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

net/banip/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
66

77
PKG_NAME:=banip
88
PKG_VERSION:=0.9.4
9-
PKG_RELEASE:=1
9+
PKG_RELEASE:=2
1010
PKG_LICENSE:=GPL-3.0-or-later
1111
PKG_MAINTAINER:=Dirk Brenken <[email protected]>
1212

net/banip/files/banip-functions.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ f_cmd() {
118118
[ "${sec_cmd}" = "true" ] && return
119119
cmd="$(command -v "${sec_cmd}" 2>/dev/null)"
120120
fi
121-
[ -x "${cmd}" ] && printf "%s" "${cmd}" || f_log "emerg" "command '${pri_cmd:-"-"}'/'${sec_cmd:-"-"}' not found"
121+
if [ -x "${cmd}" ]; then
122+
printf "%s" "${cmd}"
123+
else
124+
f_log "emerg" "command '${pri_cmd:-"-"}'/'${sec_cmd:-"-"}' not found"
125+
fi
122126
else
123127
printf "%s" "${cmd}"
124128
fi
@@ -1560,7 +1564,7 @@ f_mail() {
15601564
# log monitor
15611565
#
15621566
f_monitor() {
1563-
local logread_cmd loglimit_cmd nft_expiry line proto ip log_raw log_count rdap_log rdap_rc rdap_elements rdap_info
1567+
local daemon logread_cmd loglimit_cmd nft_expiry line proto ip log_raw log_count rdap_log rdap_rc rdap_elements rdap_info
15641568

15651569
if [ -f "${ban_logreadfile}" ]; then
15661570
logread_cmd="${ban_logreadcmd} -qf ${ban_logreadfile} 2>/dev/null | ${ban_grepcmd} -e \"${ban_logterm%%??}\" 2>/dev/null"
@@ -1575,14 +1579,20 @@ f_monitor() {
15751579
[ -n "${ban_nftexpiry}" ] && nft_expiry="timeout $(printf "%s" "${ban_nftexpiry}" | "${ban_grepcmd}" -oE "([0-9]+[d|h|m|s])+$")"
15761580
eval "${logread_cmd}" |
15771581
while read -r line; do
1578-
: >"${ban_rdapfile}"
15791582
proto=""
1583+
: >"${ban_rdapfile}"
1584+
[ -z "${daemon}" ] && daemon="$(printf "%s" "${line}" | "${ban_awkcmd}" 'BEGIN{RS="dropbear"}{if(!seen[RT]++)printf "%s",RT}')" || daemon="sshd"
15801585
ip="$(printf "%s" "${line}" | "${ban_awkcmd}" 'BEGIN{RS="(([0-9]{1,3}\\.){3}[0-9]{1,3})+"}{if(!seen[RT]++)printf "%s ",RT}')"
15811586
ip="$(f_trim "${ip}")"
15821587
ip="${ip##* }"
15831588
[ -n "${ip}" ] && proto="v4"
15841589
if [ -z "${proto}" ]; then
1585-
ip="$(printf "%s" "${line}" | "${ban_awkcmd}" 'BEGIN{RS="([A-Fa-f0-9]{1,4}::?){3,7}[A-Fa-f0-9]{1,4}"}{if(!seen[RT]++)printf "%s ",RT}')"
1590+
if [ "${daemon}" = "dropbear" ]; then
1591+
ip="$(printf "%s" "${line}" | "${ban_awkcmd}" 'BEGIN{RS="([A-Fa-f0-9]{1,4}::?){3,7}([A-Fa-f0-9]:?)+"}{if(!seen[RT]++)printf "%s ",RT}')"
1592+
ip="${ip%:*}"
1593+
else
1594+
ip="$(printf "%s" "${line}" | "${ban_awkcmd}" 'BEGIN{RS="([A-Fa-f0-9]{1,4}::?){3,7}[A-Fa-f0-9]{1,4}"}{if(!seen[RT]++)printf "%s ",RT}')"
1595+
fi
15861596
ip="$(f_trim "${ip}")"
15871597
ip="${ip##* }"
15881598
[ -n "${ip}" ] && proto="v6"

0 commit comments

Comments
 (0)