2021-03-04 14:30:38 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
IPSET_DIR="$(dirname "$0")"
|
|
|
|
IPSET_DIR="$(cd "$IPSET_DIR"; pwd)"
|
|
|
|
|
|
|
|
. "$IPSET_DIR/def.sh"
|
|
|
|
|
|
|
|
ZREESTR="$TMPDIR/reestr.txt"
|
|
|
|
#ZURL_REESTR=https://reestr.rublacklist.net/api/current
|
|
|
|
ZURL_REESTR=https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv
|
|
|
|
|
2021-10-19 11:22:25 +03:00
|
|
|
getuser
|
2021-03-04 14:30:38 +03:00
|
|
|
|
|
|
|
dig_reestr()
|
|
|
|
{
|
|
|
|
# $1 - grep ipmask
|
|
|
|
# $2 - iplist
|
|
|
|
# $3 - ip version : 4,6
|
|
|
|
|
|
|
|
echo processing reestr list $2
|
|
|
|
|
|
|
|
tail -n +2 "$ZREESTR" | nice -n 5 $GREP -oE "$1" | cut_local | ip2net$3 | zz "$2"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-19 11:22:25 +03:00
|
|
|
# assume all https banned by ip
|
|
|
|
curl -k --fail --max-time 600 --connect-timeout 5 --retry 3 --max-filesize 251658240 "$ZURL_REESTR" -o "$ZREESTR" ||
|
|
|
|
{
|
|
|
|
echo reestr list download failed
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
dlsize=$(LANG=C wc -c "$ZREESTR" | xargs | cut -f 1 -d ' ')
|
|
|
|
if test $dlsize -lt 1048576; then
|
|
|
|
echo reestr ip list is too small. can be bad.
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
#sed -i 's/\\n/\r\n/g' $ZREESTR
|
2021-03-04 14:30:38 +03:00
|
|
|
|
2021-10-19 11:22:25 +03:00
|
|
|
get_ip_regex
|
2021-03-04 14:30:38 +03:00
|
|
|
|
2021-10-19 11:22:25 +03:00
|
|
|
[ "$DISABLE_IPV4" != "1" ] && {
|
|
|
|
dig_reestr "$REG_IPV4" "$ZIPLIST" 4
|
|
|
|
}
|
2021-03-04 14:30:38 +03:00
|
|
|
|
2021-10-19 11:22:25 +03:00
|
|
|
[ "$DISABLE_IPV6" != "1" ] && {
|
|
|
|
dig_reestr "$REG_IPV6" "$ZIPLIST6" 6
|
2021-10-19 11:21:18 +03:00
|
|
|
}
|
2021-03-04 14:30:38 +03:00
|
|
|
|
2021-10-19 11:22:25 +03:00
|
|
|
rm -f "$ZREESTR"
|
|
|
|
|
2021-03-04 14:30:38 +03:00
|
|
|
"$IPSET_DIR/create_ipset.sh"
|