mirror of
https://github.com/bol-van/zapret.git
synced 2025-04-17 04:22:59 +03:00
support subnet and IP bans in get_combined.sh
This commit is contained in:
parent
e106a0c668
commit
da52d4f4ca
@ -8,20 +8,20 @@ EXEDIR=$(dirname $SCRIPT)
|
||||
|
||||
create_ipset()
|
||||
{
|
||||
ipset flush $1 2>/dev/null || ipset create $1 hash:ip maxelem 262144
|
||||
for f in "$2" "$3"
|
||||
ipset flush $2 2>/dev/null || ipset create $2 $1 maxelem 262144
|
||||
for f in "$3" "$4"
|
||||
do
|
||||
[ -f "$f" ] && {
|
||||
echo Adding to ipset $1 : $f
|
||||
echo Adding to ipset $2 \($1\) : $f
|
||||
if [ -f "$ZIPLIST_EXCLUDE" ] ; then
|
||||
grep -vxFf $ZIPLIST_EXCLUDE "$f" | sort -u | sed -nre "s/^.*$/add $1 &/p" | ipset -! restore
|
||||
grep -vxFf $ZIPLIST_EXCLUDE "$f" | sort -u | sed -nre "s/^.*$/add $2 &/p" | ipset -! restore
|
||||
else
|
||||
sort -u "$f" | sed -nre "s/^.*$/add $1 &/p" | ipset -! restore
|
||||
sort -u "$f" | sed -nre "s/^.*$/add $2 &/p" | ipset -! restore
|
||||
fi
|
||||
}
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
create_ipset $ZIPSET $ZIPLIST $ZIPLIST_USER
|
||||
create_ipset $ZIPSET_IPBAN $ZIPLIST_IPBAN $ZIPLIST_USER_IPBAN
|
||||
create_ipset hash:ip $ZIPSET $ZIPLIST $ZIPLIST_USER
|
||||
create_ipset hash:net $ZIPSET_IPBAN $ZIPLIST_IPBAN $ZIPLIST_USER_IPBAN
|
||||
|
@ -21,8 +21,9 @@ if test $dlsize -lt 1048576; then
|
||||
exit 2
|
||||
fi
|
||||
sed -i 's/\\n/\r\n/g' $ZREESTR
|
||||
grep "https://" $ZREESTR |
|
||||
grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' |
|
||||
# find entries with https or without domain name - they should be banned by IP
|
||||
(grep "https://" $ZREESTR ; grep -vE ";[a-z|*|_|0-9|\-]+\.[a-z|*|_|0-9|\-]+" $ZREESTR ) |
|
||||
grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(/[0-9]+)?' |
|
||||
cut_local |
|
||||
sort -u >$ZIPLIST_IPBAN
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user