From d8749c7550d0d98ed435f3c686b8c2d742ac02da Mon Sep 17 00:00:00 2001 From: bol-van Date: Sat, 18 Jun 2022 15:43:15 +0300 Subject: [PATCH] ipset: always resolve ipban list --- ipset/def.sh | 18 ++++++++++++++---- ipset/get_antizapret_domains.sh | 2 +- ipset/get_config.sh | 2 +- ipset/get_ipban.sh | 11 +++++++++++ ipset/get_reestr_hostlist.sh | 2 +- 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100755 ipset/get_ipban.sh diff --git a/ipset/def.sh b/ipset/def.sh index 141f666..c64720d 100644 --- a/ipset/def.sh +++ b/ipset/def.sh @@ -222,6 +222,13 @@ getexclude() return 0 } +_get_ipban() +{ + [ -f "$ZUSERLIST_IPBAN" ] && { + [ "$DISABLE_IPV4" != "1" ] && filedigger "$ZUSERLIST_IPBAN" 4 | cut_local | sort -u > "$ZIPLIST_USER_IPBAN" + [ "$DISABLE_IPV6" != "1" ] && filedigger "$ZUSERLIST_IPBAN" 6 | cut_local6 | sort -u > "$ZIPLIST_USER_IPBAN6" + } +} getuser() { getexclude || return @@ -229,10 +236,13 @@ getuser() [ "$DISABLE_IPV4" != "1" ] && filedigger "$ZUSERLIST" 4 | cut_local | sort -u > "$ZIPLIST_USER" [ "$DISABLE_IPV6" != "1" ] && filedigger "$ZUSERLIST" 6 | cut_local6 | sort -u > "$ZIPLIST_USER6" } - [ -f "$ZUSERLIST_IPBAN" ] && { - [ "$DISABLE_IPV4" != "1" ] && filedigger "$ZUSERLIST_IPBAN" 4 | cut_local | sort -u > "$ZIPLIST_USER_IPBAN" - [ "$DISABLE_IPV6" != "1" ] && filedigger "$ZUSERLIST_IPBAN" 6 | cut_local6 | sort -u > "$ZIPLIST_USER_IPBAN6" - } + _get_ipban + return 0 +} +getipban() +{ + getexclude || return + _get_ipban return 0 } diff --git a/ipset/get_antizapret_domains.sh b/ipset/get_antizapret_domains.sh index 277e8fd..b1cbe4c 100755 --- a/ipset/get_antizapret_domains.sh +++ b/ipset/get_antizapret_domains.sh @@ -7,7 +7,7 @@ IPSET_DIR="$(cd "$IPSET_DIR"; pwd)" # useful in case ipban set is used in custom scripts FAIL= -getuser || FAIL=1 +getipban || FAIL=1 "$IPSET_DIR/create_ipset.sh" [ -n "$FAIL" ] && exit diff --git a/ipset/get_config.sh b/ipset/get_config.sh index 9d73133..f751f18 100755 --- a/ipset/get_config.sh +++ b/ipset/get_config.sh @@ -6,5 +6,5 @@ IPSET_DIR="$(cd "$IPSET_DIR"; pwd)" . "$IPSET_DIR/../config" -[ -z "$GETLIST" ] && GETLIST=get_exclude.sh +[ -z "$GETLIST" ] && GETLIST=get_ipban.sh [ -x "$IPSET_DIR/$GETLIST" ] && exec "$IPSET_DIR/$GETLIST" diff --git a/ipset/get_ipban.sh b/ipset/get_ipban.sh new file mode 100755 index 0000000..825f342 --- /dev/null +++ b/ipset/get_ipban.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# resolve only ipban user host list + +IPSET_DIR="$(dirname "$0")" +IPSET_DIR="$(cd "$IPSET_DIR"; pwd)" + +. "$IPSET_DIR/def.sh" + +getipban + +"$IPSET_DIR/create_ipset.sh" diff --git a/ipset/get_reestr_hostlist.sh b/ipset/get_reestr_hostlist.sh index b0c9393..bab1818 100755 --- a/ipset/get_reestr_hostlist.sh +++ b/ipset/get_reestr_hostlist.sh @@ -7,7 +7,7 @@ IPSET_DIR="$(cd "$IPSET_DIR"; pwd)" # useful in case ipban set is used in custom scripts FAIL= -getuser || FAIL=1 +getipban || FAIL=1 "$IPSET_DIR/create_ipset.sh" [ -n "$FAIL" ] && exit