2021-03-04 14:30:38 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
IPSET_DIR="$(dirname "$0")"
|
|
|
|
IPSET_DIR="$(cd "$IPSET_DIR"; pwd)"
|
|
|
|
|
|
|
|
. "$IPSET_DIR/def.sh"
|
|
|
|
|
|
|
|
# useful in case ipban set is used in custom scripts
|
2021-10-19 11:22:43 +03:00
|
|
|
FAIL=
|
2022-06-18 15:43:15 +03:00
|
|
|
getipban || FAIL=1
|
2021-03-04 14:30:38 +03:00
|
|
|
"$IPSET_DIR/create_ipset.sh"
|
2021-10-19 11:22:43 +03:00
|
|
|
[ -n "$FAIL" ] && exit
|
2021-03-04 14:30:38 +03:00
|
|
|
|
|
|
|
ZREESTR="$TMPDIR/zapret.txt"
|
|
|
|
#ZURL=https://reestr.rublacklist.net/api/current
|
2022-12-11 09:58:04 +03:00
|
|
|
ZURL_REESTR=https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv
|
2021-03-04 14:30:38 +03:00
|
|
|
|
2022-12-11 09:52:01 +03:00
|
|
|
curl -H "Accept-Encoding: gzip" -k --fail --max-time 600 --connect-timeout 5 --retry 3 --max-filesize 251658240 "$ZURL_REESTR" | gunzip - >"$ZREESTR" ||
|
2021-03-04 14:30:38 +03:00
|
|
|
{
|
|
|
|
echo reestr list download failed
|
|
|
|
exit 2
|
|
|
|
}
|
2021-12-12 12:58:58 +03:00
|
|
|
|
|
|
|
reestr_list()
|
|
|
|
{
|
|
|
|
LANG=C cut -s -f2 -d';' "$ZREESTR" | LANG=C nice -n 5 sed -Ee 's/^\*\.(.+)$/\1/' -ne 's/^[a-z0-9A-Z._-]+$/&/p' | $AWK '{ print tolower($0) }'
|
|
|
|
}
|
|
|
|
|
2021-03-04 14:30:38 +03:00
|
|
|
dlsize=$(LANG=C wc -c "$ZREESTR" | xargs | cut -f 1 -d ' ')
|
|
|
|
if test $dlsize -lt 204800; then
|
|
|
|
echo list file is too small. can be bad.
|
|
|
|
exit 2
|
|
|
|
fi
|
2021-12-12 12:58:58 +03:00
|
|
|
|
2022-07-27 16:35:05 +03:00
|
|
|
reestr_list | sort -u | zz "$ZHOSTLIST"
|
2021-12-12 12:58:58 +03:00
|
|
|
|
2021-03-04 14:30:38 +03:00
|
|
|
rm -f "$ZREESTR"
|
|
|
|
|
|
|
|
hup_zapret_daemons
|
|
|
|
|
|
|
|
exit 0
|