support for zapret-ip-exclude.txt

This commit is contained in:
bolvan 2016-11-26 20:01:33 +03:00
parent b8ad407912
commit 918a088527
2 changed files with 7 additions and 13 deletions

View File

@ -6,25 +6,18 @@ EXEDIR=$(dirname $SCRIPT)
. "$EXEDIR/def.sh" . "$EXEDIR/def.sh"
create_ipset() create_ipset()
{ {
ipset flush $1 2>/dev/null || ipset create $1 hash:ip ipset flush $1 2>/dev/null || ipset create $1 hash:ip
local TEMPIPSET=/tmp/ipset.$1.tmp
for f in "$2" "$3" for f in "$2" "$3"
do do
[ -f $TEMPIPSET ] && rm -f $TEMPIPSET
[ -f "$f" ] && { [ -f "$f" ] && {
echo Adding to ipset "$1" : $f echo Adding to ipset $1 : $f
touch $TEMPIPSET if [ -f "$ZIPLIST_EXCLUDE" ] ; then
sort $f | uniq | while read ip; grep -vxf $ZIPLIST_EXCLUDE "$f" | sort -u | while read ip; do echo add $1 $ip; done | ipset -! restore
do else
echo add $1 $ip >>$TEMPIPSET sort -u "$f" | while read ip; do echo add $1 $ip; done | ipset -! restore
done fi
ipset -! restore <$TEMPIPSET 2>&1
rm -f $TEMPIPSET
} }
done done
} }

View File

@ -1,5 +1,6 @@
ZIPSET=zapret ZIPSET=zapret
ZIPLIST=$EXEDIR/zapret-ip.txt ZIPLIST=$EXEDIR/zapret-ip.txt
ZIPLIST_EXCLUDE=$EXEDIR/zapret-ip-exclude.txt
ZIPLIST_USER=$EXEDIR/zapret-ip-user.txt ZIPLIST_USER=$EXEDIR/zapret-ip-user.txt
ZUSERLIST=$EXEDIR/zapret-hosts-user.txt ZUSERLIST=$EXEDIR/zapret-hosts-user.txt