get_combined.sh

This commit is contained in:
bolvan 2017-05-06 09:47:30 +03:00
parent 098c642598
commit 81dbfc327a
3 changed files with 44 additions and 3 deletions

View File

@ -12,9 +12,9 @@ ZUSERLIST_IPBAN=$EXEDIR/zapret-hosts-user-ipban.txt
getuser()
{
[ -f $ZUSERLIST ] && {
dig A +short +time=8 +tries=2 -f $ZUSERLIST | grep -E '^[^;].*[^.]$' | grep -vE '^192.168.[0-9]*.[0-9]*$' | grep -vE '^127.[0-9]*.[0-9]*.[0-9]*$' | grep -vE '^10.[0-9]*.[0-9]*.[0-9]*$' | sort | uniq >$ZIPLIST_USER
dig A +short +time=8 +tries=2 -f $ZUSERLIST | grep -E '^[^;].*[^.]$' | grep -vE '^192\.168\.[0-9]+.[0-9]+$' | grep -vE '^127\.[0-9]+\.[0-9]+\.[0-9]+$' | grep -vE '^10\.[0-9]+\.[0-9]+\.[0-9]+$' | sort -u >$ZIPLIST_USER
}
[ -f $ZUSERLIST_IPBAN ] && {
dig A +short +time=8 +tries=2 -f $ZUSERLIST_IPBAN | grep -E '^[^;].*[^.]$' | grep -vE '^192.168.[0-9]*.[0-9]*$' | grep -vE '^127.[0-9]*.[0-9]*.[0-9]*$' | grep -vE '^10.[0-9]*.[0-9]*.[0-9]*$' | sort | uniq >$ZIPLIST_USER_IPBAN
dig A +short +time=8 +tries=2 -f $ZUSERLIST_IPBAN | grep -E '^[^;].*[^.]$' | grep -vE '^192\.168\.[0-9]+\.[0-9]+$' | grep -vE '^127\.[0-9]+\.[0-9]+\.[0-9]+$' | grep -vE '^10\.[0-9]+\.[0-9]+\.[0-9]+$' | sort -u >$ZIPLIST_USER_IPBAN
}
}

41
ipset/get_combined.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh
# get rublacklist and resolve it
SCRIPT=$(readlink -f $0)
EXEDIR=$(dirname $SCRIPT)
. "$EXEDIR/def.sh"
ZREESTR=/tmp/reestr.txt
ZANTIZAPRET=/tmp/antizapret.txt
ZURL_REESTR=http://reestr.rublacklist.net/api/current
ZURL_ANTIZAPRET=http://antizapret.prostovpn.org/iplist.txt
getuser
curl --fail --max-time 300 --max-filesize 41943040 "$ZURL_REESTR" |
grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' |
grep -vE '^192\.168\.[0-9]+\.[0-9]+$' |
grep -vE '^127\.[0-9]+\.[0-9]+\.[0-9]+$' |
grep -vE '^10\.[0-9]+\.[0-9]+\.[0-9]+$' |
sort -u >$ZREESTR
dlsize=$(wc -c "$ZREESTR" | cut -f 1 -d ' ')
if test $dlsize -lt 10240; then
echo reestr ip list is too small. can be bad.
exit 2
fi
curl --fail --max-time 300 --max-filesize 33554432 -k -L "$ZURL_ANTIZAPRET" |
grep -vE '^192\.168\.[0-9]+\.[0-9]+$' |
grep -vE '^127\.[0-9]+\.[0-9]+\.[0-9]+$' |
grep -vE '^10\.[0-9]+\.[0-9]+\.[0-9]+$' >$ZANTIZAPRET
dlsize=$(wc -c "$ZANTIZAPRET" | cut -f 1 -d ' ')
if test $dlsize -lt 10240; then
echo reestr ip list is too small. can be bad.
exit 2
fi
grep -vFf $ZREESTR $ZANTIZAPRET >$ZIPLIST
mv -f $ZREESTR $ZIPLIST_IPBAN
rm -f $ZANTIZAPRET
"$EXEDIR/create_ipset.sh"

View File

@ -13,7 +13,7 @@ ZURL=http://reestr.rublacklist.net/api/current
getuser
curl --fail --max-time 300 --max-filesize 20971520 "$ZURL" >$ZREESTR && {
curl --fail --max-time 300 --max-filesize 41943040 "$ZURL" >$ZREESTR && {
dlsize=$(wc -c "$ZREESTR" | cut -f 1 -d ' ')
if test $dlsize -lt 204800; then
echo list file is too small. can be bad.