From 918a088527227c65c49783b3329c43e1f6258964 Mon Sep 17 00:00:00 2001 From: bolvan Date: Sat, 26 Nov 2016 20:01:33 +0300 Subject: [PATCH] support for zapret-ip-exclude.txt --- ipset/create_ipset.sh | 19 ++++++------------- ipset/def.sh | 1 + 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ipset/create_ipset.sh b/ipset/create_ipset.sh index bc7be11..51ccc82 100755 --- a/ipset/create_ipset.sh +++ b/ipset/create_ipset.sh @@ -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 } diff --git a/ipset/def.sh b/ipset/def.sh index 158371a..473adf9 100755 --- a/ipset/def.sh +++ b/ipset/def.sh @@ -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