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"
create_ipset()
{
ipset flush $1 2>/dev/null || ipset create $1 hash:ip
local TEMPIPSET=/tmp/ipset.$1.tmp
for f in "$2" "$3"
do
[ -f $TEMPIPSET ] && rm -f $TEMPIPSET
[ -f "$f" ] && {
echo Adding to ipset "$1" : $f
touch $TEMPIPSET
sort $f | uniq | while read ip;
do
echo add $1 $ip >>$TEMPIPSET
done
ipset -! restore <$TEMPIPSET 2>&1
rm -f $TEMPIPSET
echo Adding to ipset $1 : $f
if [ -f "$ZIPLIST_EXCLUDE" ] ; then
grep -vxf $ZIPLIST_EXCLUDE "$f" | sort -u | while read ip; do echo add $1 $ip; done | ipset -! restore
else
sort -u "$f" | while read ip; do echo add $1 $ip; done | ipset -! restore
fi
}
done
}

View File

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