zapret/ipset/def.sh

29 lines
1022 B
Bash
Raw Normal View History

2017-05-11 18:36:52 +03:00
TMPDIR=/tmp
2016-03-04 12:03:34 +03:00
ZIPSET=zapret
2016-02-15 16:34:45 +03:00
ZIPLIST=$EXEDIR/zapret-ip.txt
2016-11-26 20:01:33 +03:00
ZIPLIST_EXCLUDE=$EXEDIR/zapret-ip-exclude.txt
2016-02-15 16:34:45 +03:00
ZIPLIST_USER=$EXEDIR/zapret-ip-user.txt
ZUSERLIST=$EXEDIR/zapret-hosts-user.txt
2016-03-04 12:03:34 +03:00
ZIPSET_IPBAN=ipban
ZIPLIST_IPBAN=$EXEDIR/zapret-ip-ipban.txt
ZIPLIST_USER_IPBAN=$EXEDIR/zapret-ip-user-ipban.txt
ZUSERLIST_IPBAN=$EXEDIR/zapret-hosts-user-ipban.txt
2016-03-16 08:33:26 +03:00
getuser()
{
[ -f $ZUSERLIST ] && {
2017-05-06 09:47:30 +03:00
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
2016-03-16 08:33:26 +03:00
}
[ -f $ZUSERLIST_IPBAN ] && {
2017-05-06 09:47:30 +03:00
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
2016-03-16 08:33:26 +03:00
}
2017-05-11 18:36:52 +03:00
}
cut_local()
{
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]+$'
}