mirror of
https://github.com/bol-van/zapret.git
synced 2025-05-24 22:32:58 +03:00
history purge
This commit is contained in:
19
ipset/antifilter.helper
Normal file
19
ipset/antifilter.helper
Normal file
@@ -0,0 +1,19 @@
|
||||
get_antifilter()
|
||||
{
|
||||
# $1 - list url
|
||||
# $2 - target file
|
||||
local ZIPLISTTMP="$TMPDIR/zapret-ip.txt"
|
||||
|
||||
[ "$DISABLE_IPV4" != "1" ] && {
|
||||
curl --fail --max-time 150 --connect-timeout 20 --max-filesize 41943040 -k -L "$1" | cut_local >"$ZIPLISTTMP" &&
|
||||
{
|
||||
dlsize=$(wc -c "$ZIPLISTTMP" | cut -f 1 -d ' ')
|
||||
if test $dlsize -lt 204800; then
|
||||
echo list file is too small. can be bad.
|
||||
exit 2
|
||||
fi
|
||||
cat "$ZIPLISTTMP" | zz "$2"
|
||||
rm -f "$ZIPLISTTMP" "$2"
|
||||
}
|
||||
}
|
||||
}
|
8
ipset/clear_lists.sh
Executable file
8
ipset/clear_lists.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
|
||||
rm -f "$ZIPLIST"* "$ZIPLIST6"* "$ZIPLIST_USER" "$ZIPLIST_USER6" "$ZIPLIST_IPBAN"* "$ZIPLIST_IPBAN6"* "$ZIPLIST_USER_IPBAN" "$ZIPLIST_USER_IPBAN6" "$ZIPLIST_EXCLUDE" "$ZIPLIST_EXCLUDE6" "$ZHOSTLIST"*
|
145
ipset/create_ipset.sh
Executable file
145
ipset/create_ipset.sh
Executable file
@@ -0,0 +1,145 @@
|
||||
#!/bin/sh
|
||||
# create ipset from resolved ip's
|
||||
# $1=no-update - do not update ipset, only create if its absent
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
[ -z "$IPSET_OPT" ] && IPSET_OPT="hashsize 262144 maxelem 2097152"
|
||||
[ -z "$IPSET_OPT_EXCLUDE" ] && IPSET_OPT_EXCLUDE="hashsize 1024 maxelem 65536"
|
||||
|
||||
IP2NET="$EXEDIR/../ip2net/ip2net"
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
IPSET_CMD="$TMPDIR/ipset_cmd.txt"
|
||||
IPSET_SAVERAM_CHUNK_SIZE=20000
|
||||
IPSET_SAVERAM_MIN_FILESIZE=131072
|
||||
|
||||
|
||||
while [ -n "$1" ]; do
|
||||
[ "$1" = "no-update" ] && NO_UPDATE=1
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
file_extract_lines()
|
||||
{
|
||||
# $1 - filename
|
||||
# $2 - from line (starting with 0)
|
||||
# $3 - line count
|
||||
# awk "{ err=1 } NR < $(($2+1)) { next } { print; err=0 } NR == $(($2+$3)) { exit err } END {exit err}" "$1"
|
||||
awk "NR < $(($2+1)) { next } { print } NR == $(($2+$3)) { exit }" "$1"
|
||||
}
|
||||
ipset_restore_chunked()
|
||||
{
|
||||
# $1 - filename
|
||||
# $2 - chunk size
|
||||
local pos lines
|
||||
[ -f "$1" ] || return
|
||||
lines=$(wc -l <"$1")
|
||||
pos=$lines
|
||||
while [ "$pos" -gt "0" ]; do
|
||||
pos=$((pos-$2))
|
||||
[ "$pos" -lt "0" ] && pos=0
|
||||
file_extract_lines "$1" $pos $2 | ipset -! restore
|
||||
sed -i "$(($pos+1)),$ d" "$1"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
sortu()
|
||||
{
|
||||
sort -u
|
||||
}
|
||||
ip2net4()
|
||||
{
|
||||
"$IP2NET" -4 $IP2NET_OPT4
|
||||
}
|
||||
ip2net6()
|
||||
{
|
||||
"$IP2NET" -6 $IP2NET_OPT6
|
||||
}
|
||||
ipset_get_script()
|
||||
{
|
||||
# $1 - filename
|
||||
# $2 - ipset name
|
||||
# $3 - "6" = ipv6
|
||||
local filter=sortu
|
||||
[ -x "$IP2NET" ] && filter=ip2net$3
|
||||
zzcat "$1" | $filter | sed -nre "s/^.+$/add $2 &/p"
|
||||
}
|
||||
|
||||
ipset_restore()
|
||||
{
|
||||
# $1 - filename
|
||||
# $2 - ipset name
|
||||
# $3 - "6" = ipv6
|
||||
zzexist "$1" || return
|
||||
local fsize=$(zzsize "$1")
|
||||
local svram=0
|
||||
# do not saveram small files. file can also be gzipped
|
||||
[ "$SAVERAM" = "1" ] && [ "$fsize" -ge "$IPSET_SAVERAM_MIN_FILESIZE" ] && svram=1
|
||||
|
||||
local T="Adding to ipset $2 ($IPSTYPE"
|
||||
[ -x "$IP2NET" ] && T="$T, ip2net"
|
||||
[ "$svram" = "1" ] && T="$T, saveram"
|
||||
T="$T) : $f"
|
||||
echo $T
|
||||
|
||||
if [ "$svram" = "1" ]; then
|
||||
ipset_get_script "$1" "$2" "$3" >"$IPSET_CMD"
|
||||
ipset_restore_chunked "$IPSET_CMD" $IPSET_SAVERAM_CHUNK_SIZE
|
||||
rm -f "$IPSET_CMD"
|
||||
else
|
||||
ipset_get_script "$1" "$2" "$3" | ipset -! restore
|
||||
fi
|
||||
}
|
||||
|
||||
create_ipset()
|
||||
{
|
||||
local IPSTYPE
|
||||
if [ -x "$IP2NET" ]; then
|
||||
IPSTYPE=hash:net
|
||||
else
|
||||
IPSTYPE=$3
|
||||
fi
|
||||
if [ "$1" -eq "6" ]; then
|
||||
FAMILY=inet6
|
||||
else
|
||||
FAMILY=inet
|
||||
fi
|
||||
ipset create $2 $IPSTYPE $4 family $FAMILY 2>/dev/null || {
|
||||
[ "$NO_UPDATE" = "1" ] && return
|
||||
}
|
||||
ipset flush $2
|
||||
for f in "$5" "$6" ; do
|
||||
ipset_restore "$f" "$2" $1
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
oom_adjust_high
|
||||
|
||||
# ipset seem to buffer the whole script to memory
|
||||
# on low RAM system this can cause oom errors
|
||||
# in SAVERAM mode we feed script lines in portions starting from the end, while truncating source file to free /tmp space
|
||||
# only /tmp is considered tmpfs. other locations mean tmpdir was redirected to a disk
|
||||
SAVERAM=0
|
||||
[ "$TMPDIR" = "/tmp" ] && {
|
||||
RAMSIZE=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||
[ "$RAMSIZE" -lt "110000" ] && SAVERAM=1
|
||||
}
|
||||
|
||||
[ "$DISABLE_IPV4" != "1" ] && {
|
||||
create_ipset 4 $ZIPSET hash:ip "$IPSET_OPT" "$ZIPLIST" "$ZIPLIST_USER"
|
||||
create_ipset 4 $ZIPSET_IPBAN hash:ip "$IPSET_OPT" "$ZIPLIST_IPBAN" "$ZIPLIST_USER_IPBAN"
|
||||
create_ipset 4 $ZIPSET_EXCLUDE hash:net "$IPSET_OPT_EXCLUDE" "$ZIPLIST_EXCLUDE"
|
||||
}
|
||||
|
||||
[ "$DISABLE_IPV6" != "1" ] && {
|
||||
create_ipset 6 $ZIPSET6 hash:ip "$IPSET_OPT" "$ZIPLIST6" "$ZIPLIST_USER6"
|
||||
create_ipset 6 $ZIPSET_IPBAN6 hash:ip "$IPSET_OPT" "$ZIPLIST_IPBAN6" "$ZIPLIST_USER_IPBAN6"
|
||||
create_ipset 6 $ZIPSET_EXCLUDE6 hash:net "$IPSET_OPT_EXCLUDE" "$ZIPLIST_EXCLUDE6"
|
||||
}
|
||||
|
||||
true
|
103
ipset/def.sh
Normal file
103
ipset/def.sh
Normal file
@@ -0,0 +1,103 @@
|
||||
. "$EXEDIR/../config"
|
||||
|
||||
[ -z "$TMPDIR" ] && TMPDIR=/tmp
|
||||
ZIPSET=zapret
|
||||
ZIPSET6=zapret6
|
||||
ZIPSET_EXCLUDE=nozapret
|
||||
ZIPSET_EXCLUDE6=nozapret6
|
||||
ZIPLIST="$EXEDIR/zapret-ip.txt"
|
||||
ZIPLIST6="$EXEDIR/zapret-ip6.txt"
|
||||
ZIPLIST_EXCLUDE="$EXEDIR/zapret-ip-exclude.txt"
|
||||
ZIPLIST_EXCLUDE6="$EXEDIR/zapret-ip-exclude6.txt"
|
||||
ZIPLIST_USER="$EXEDIR/zapret-ip-user.txt"
|
||||
ZIPLIST_USER6="$EXEDIR/zapret-ip-user6.txt"
|
||||
ZUSERLIST="$EXEDIR/zapret-hosts-user.txt"
|
||||
ZHOSTLIST="$EXEDIR/zapret-hosts.txt"
|
||||
|
||||
ZIPSET_IPBAN=ipban
|
||||
ZIPSET_IPBAN6=ipban6
|
||||
ZIPLIST_IPBAN="$EXEDIR/zapret-ip-ipban.txt"
|
||||
ZIPLIST_IPBAN6="$EXEDIR/zapret-ip-ipban6.txt"
|
||||
ZIPLIST_USER_IPBAN="$EXEDIR/zapret-ip-user-ipban.txt"
|
||||
ZIPLIST_USER_IPBAN6="$EXEDIR/zapret-ip-user-ipban6.txt"
|
||||
ZUSERLIST_IPBAN="$EXEDIR/zapret-hosts-user-ipban.txt"
|
||||
ZUSERLIST_EXCLUDE="$EXEDIR/zapret-hosts-user-exclude.txt"
|
||||
|
||||
MDIG="$EXEDIR/../mdig/mdig"
|
||||
[ -z "$MDIG_THREADS" ] && MDIG_THREADS=30
|
||||
|
||||
zzexist()
|
||||
{
|
||||
[ -f "$1.gz" ] || [ -f "$1" ]
|
||||
}
|
||||
zzcat()
|
||||
{
|
||||
if [ -f "$1.gz" ]; then
|
||||
gunzip -c "$1.gz"
|
||||
else
|
||||
cat "$1"
|
||||
fi
|
||||
}
|
||||
zz()
|
||||
{
|
||||
gzip -c >"$1.gz"
|
||||
}
|
||||
zzsize()
|
||||
{
|
||||
local f="$1"
|
||||
[ -f "$1.gz" ] && f="$1.gz"
|
||||
wc -c <"$f"
|
||||
}
|
||||
|
||||
digger()
|
||||
{
|
||||
# $1 - hostlist
|
||||
# $2 - family (4|6)
|
||||
>&2 echo digging $(wc -l <"$1") ipv$2 domains : "$1"
|
||||
|
||||
if [ -x "$MDIG" ]; then
|
||||
zzcat "$1" | "$MDIG" --family=$2 --threads=$MDIG_THREADS --stats=1000
|
||||
else
|
||||
local A=A
|
||||
[ "$2" = "6" ] && A=AAAA
|
||||
zzcat "$1" | dig $A +short +time=8 +tries=2 -f - | grep -E '^[^;].*[^\.]$'
|
||||
fi
|
||||
}
|
||||
|
||||
cut_local()
|
||||
{
|
||||
grep -vE '^192\.168\.|^127\.|^10\.'
|
||||
}
|
||||
cut_local6()
|
||||
{
|
||||
grep -vE '^::|fc..:|fd..:'
|
||||
}
|
||||
|
||||
oom_adjust_high()
|
||||
{
|
||||
echo setting high oom kill priority
|
||||
echo -n 100 >/proc/$$/oom_score_adj
|
||||
}
|
||||
|
||||
getexclude()
|
||||
{
|
||||
oom_adjust_high
|
||||
|
||||
[ -f "$ZUSERLIST_EXCLUDE" ] && {
|
||||
[ "$DISABLE_IPV4" != "1" ] && digger "$ZUSERLIST_EXCLUDE" 4 | sort -u > "$ZIPLIST_EXCLUDE"
|
||||
[ "$DISABLE_IPV6" != "1" ] && digger "$ZUSERLIST_EXCLUDE" 6 | sort -u > "$ZIPLIST_EXCLUDE6"
|
||||
}
|
||||
}
|
||||
|
||||
getuser()
|
||||
{
|
||||
getexclude
|
||||
[ -f "$ZUSERLIST" ] && {
|
||||
[ "$DISABLE_IPV4" != "1" ] && digger "$ZUSERLIST" 4 | cut_local | sort -u > "$ZIPLIST_USER"
|
||||
[ "$DISABLE_IPV6" != "1" ] && digger "$ZUSERLIST" 6 | cut_local6 | sort -u > "$ZIPLIST_USER6"
|
||||
}
|
||||
[ -f "$ZUSERLIST_IPBAN" ] && {
|
||||
[ "$DISABLE_IPV4" != "1" ] && digger "$ZUSERLIST_IPBAN" 4 | cut_local | sort -u > "$ZIPLIST_USER_IPBAN"
|
||||
[ "$DISABLE_IPV6" != "1" ] && digger "$ZUSERLIST_IPBAN" 6 | cut_local6 | sort -u > "$ZIPLIST_USER_IPBAN6"
|
||||
}
|
||||
}
|
14
ipset/get_antifilter_ip.sh
Executable file
14
ipset/get_antifilter_ip.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
|
||||
getuser
|
||||
|
||||
. "$EXEDIR/antifilter.helper"
|
||||
|
||||
get_antifilter https://antifilter.network/download/ip.lst "$ZIPLIST"
|
||||
|
||||
"$EXEDIR/create_ipset.sh"
|
14
ipset/get_antifilter_ipsmart.sh
Executable file
14
ipset/get_antifilter_ipsmart.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
|
||||
getuser
|
||||
|
||||
. "$EXEDIR/antifilter.helper"
|
||||
|
||||
get_antifilter https://antifilter.network/download/ipsmart.lst "$ZIPLIST"
|
||||
|
||||
"$EXEDIR/create_ipset.sh"
|
14
ipset/get_antifilter_ipsum.sh
Executable file
14
ipset/get_antifilter_ipsum.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
|
||||
getuser
|
||||
|
||||
. "$EXEDIR/antifilter.helper"
|
||||
|
||||
get_antifilter https://antifilter.network/download/ipsum.lst "$ZIPLIST"
|
||||
|
||||
"$EXEDIR/create_ipset.sh"
|
10
ipset/get_config.sh
Executable file
10
ipset/get_config.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# run script specified in config
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/../config"
|
||||
|
||||
[ -z "$GETLIST" ] && GETLIST=get_exclude.sh
|
||||
[ -x "$EXEDIR/$GETLIST" ] && exec "$EXEDIR/$GETLIST"
|
11
ipset/get_exclude.sh
Executable file
11
ipset/get_exclude.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# resolve user host list
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
|
||||
getexclude
|
||||
|
||||
"$EXEDIR/create_ipset.sh"
|
59
ipset/get_reestr_combined.sh
Executable file
59
ipset/get_reestr_combined.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/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
|
||||
|
||||
getuser
|
||||
|
||||
dig_reestr()
|
||||
{
|
||||
# $1 - grep ipmask
|
||||
# $2 - iplist
|
||||
# $3 - ipban list
|
||||
|
||||
local DOMMASK='^.*;[^ ;:/]+\.[^ ;:/]+;'
|
||||
local TMP="$TMPDIR/tmp.txt"
|
||||
# find entries with https or without domain name - they should be banned by IP
|
||||
# 2971-18 is TELEGRAM. lots of proxy IPs banned, list grows very large
|
||||
(grep -avE "$DOMMASK" "$ZREESTR" ; grep -a "https://" "$ZREESTR") |
|
||||
grep -av "2971-18" |
|
||||
grep -oE "$1" | cut_local | sort -u >$TMP
|
||||
|
||||
cat "$TMP" | zz "$3"
|
||||
|
||||
# other IPs go to regular zapret list
|
||||
grep -av "2971-18" "$ZREESTR" | grep -oE "$1" | cut_local | grep -xvFf "$TMP" | sort -u | zz "$2"
|
||||
|
||||
rm -f "$TMP"
|
||||
}
|
||||
|
||||
|
||||
curl -k --fail --max-time 150 --connect-timeout 5 --retry 3 --max-filesize 251658240 "$ZURL_REESTR" -o "$ZREESTR" ||
|
||||
{
|
||||
echo reestr list download failed
|
||||
exit 2
|
||||
}
|
||||
dlsize=$(wc -c "$ZREESTR" | 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
|
||||
|
||||
[ "$DISABLE_IPV4" != "1" ] && {
|
||||
dig_reestr '([0-9]{1,3}\.){3}[0-9]{1,3}(/[0-9]+)?' "$ZIPLIST" "$ZIPLIST_IPBAN"
|
||||
}
|
||||
|
||||
[ "$DISABLE_IPV6" != "1" ] && {
|
||||
dig_reestr '([0-9,a-f,A-F]{1,4}:){7}[0-9,a-f,A-F]{1,4}(/[0-9]+)?' "$ZIPLIST6" "$ZIPLIST_IPBAN6"
|
||||
}
|
||||
|
||||
rm -f "$ZREESTR"
|
||||
|
||||
"$EXEDIR/create_ipset.sh"
|
33
ipset/get_reestr_hostlist.sh
Executable file
33
ipset/get_reestr_hostlist.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
|
||||
# useful in case ipban set is used in custom scripts
|
||||
getuser
|
||||
"$EXEDIR/create_ipset.sh"
|
||||
|
||||
ZREESTR="$TMPDIR/zapret.txt"
|
||||
#ZURL=https://reestr.rublacklist.net/api/current
|
||||
ZURL=https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv
|
||||
|
||||
curl -k --fail --max-time 150 --connect-timeout 5 --retry 3 --max-filesize 251658240 "$ZURL" >"$ZREESTR" ||
|
||||
{
|
||||
echo reestr list download failed
|
||||
exit 2
|
||||
}
|
||||
dlsize=$(wc -c "$ZREESTR" | cut -f 1 -d ' ')
|
||||
if test $dlsize -lt 204800; then
|
||||
echo list file is too small. can be bad.
|
||||
exit 2
|
||||
fi
|
||||
(cut -s -f2 -d';' "$ZREESTR" | grep -a . | sed -re 's/^\*\.(.+)$/\1/' | awk '{ print tolower($0) }' ; cat "$ZUSERLIST" ) | sort -u | zz "$ZHOSTLIST"
|
||||
rm -f "$ZREESTR"
|
||||
|
||||
# force daemons to reload hostlist if they are running
|
||||
killall -HUP tpws 2>/dev/null
|
||||
killall -HUP nfqws 2>/dev/null
|
||||
|
||||
exit 0
|
47
ipset/get_reestr_ip.sh
Executable file
47
ipset/get_reestr_ip.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/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
|
||||
|
||||
getuser
|
||||
|
||||
dig_reestr()
|
||||
{
|
||||
# $1 - grep ipmask
|
||||
# $2 - iplist
|
||||
|
||||
# 2971-18 is TELEGRAM. lots of proxy IPs banned, list grows very large
|
||||
grep -av "2971-18" "$ZREESTR" | grep -oE "$1" | cut_local | sort -u | zz "$2"
|
||||
}
|
||||
|
||||
|
||||
# assume all https banned by ip
|
||||
curl -k --fail --max-time 150 --connect-timeout 5 --retry 3 --max-filesize 251658240 "$ZURL_REESTR" -o "$ZREESTR" ||
|
||||
{
|
||||
echo reestr list download failed
|
||||
exit 2
|
||||
}
|
||||
dlsize=$(wc -c "$ZREESTR" | 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
|
||||
|
||||
[ "$DISABLE_IPV4" != "1" ] && {
|
||||
dig_reestr '([0-9]{1,3}\.){3}[0-9]{1,3}(/[0-9]+)?' "$ZIPLIST"
|
||||
}
|
||||
|
||||
[ "$DISABLE_IPV6" != "1" ] && {
|
||||
dig_reestr '([0-9,a-f,A-F]{1,4}:){7}[0-9,a-f,A-F]{1,4}(/[0-9]+)?' "$ZIPLIST6"
|
||||
}
|
||||
|
||||
rm -f "$ZREESTR"
|
||||
|
||||
"$EXEDIR/create_ipset.sh"
|
54
ipset/get_reestr_resolve.sh
Executable file
54
ipset/get_reestr_resolve.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
|
||||
ZREESTR="$TMPDIR/zapret.txt"
|
||||
ZDIG="$TMPDIR/zapret-dig.txt"
|
||||
ZIPLISTTMP="$TMPDIR/zapret-ip.txt"
|
||||
#ZURL=https://reestr.rublacklist.net/api/current
|
||||
ZURL=https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv
|
||||
|
||||
getuser
|
||||
|
||||
# both disabled
|
||||
[ "$DISABLE_IPV4" = "1" ] && [ "$DISABLE_IPV6" = "1" ] && exit 0
|
||||
|
||||
curl -k --fail --max-time 150 --connect-timeout 5 --retry 3 --max-filesize 251658240 "$ZURL" >"$ZREESTR" ||
|
||||
{
|
||||
echo reestr list download failed
|
||||
exit 2
|
||||
}
|
||||
dlsize=$(wc -c "$ZREESTR" | cut -f 1 -d ' ')
|
||||
if test $dlsize -lt 204800; then
|
||||
echo list file is too small. can be bad.
|
||||
exit 2
|
||||
fi
|
||||
echo preparing dig list ..
|
||||
#sed -i 's/\\n/\r\n/g' $ZREESTR
|
||||
#sed -nre 's/^[^;]*;([^;|\\]{4,250})\;.*$/\1/p' $ZREESTR | sort | uniq >$ZDIG
|
||||
cut -f2 -d ';' "$ZREESTR" | grep -avE '^$|\*|:' >"$ZDIG"
|
||||
rm -f "$ZREESTR"
|
||||
|
||||
echo digging started. this can take long ...
|
||||
|
||||
[ "$DISABLE_IPV4" != "1" ] && {
|
||||
digger "$ZDIG" 4 | cut_local >"$ZIPLISTTMP" || {
|
||||
rm -f "$ZDIG"
|
||||
exit 1
|
||||
}
|
||||
sort -u "$ZIPLISTTMP" | zz "$ZIPLIST"
|
||||
rm -f "$ZIPLISTTMP"
|
||||
}
|
||||
[ "$DISABLE_IPV6" != "1" ] && {
|
||||
digger "$ZDIG" 6 | cut_local6 >"$ZIPLISTTMP" || {
|
||||
rm -f "$ZDIG"
|
||||
exit 1
|
||||
}
|
||||
sort -u "$ZIPLISTTMP" | zz "$ZIPLIST6"
|
||||
rm -f "$ZIPLISTTMP"
|
||||
}
|
||||
rm -f "$ZDIG"
|
||||
"$EXEDIR/create_ipset.sh"
|
11
ipset/get_user.sh
Executable file
11
ipset/get_user.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# resolve user host list
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
EXEDIR=$(dirname "$SCRIPT")
|
||||
|
||||
. "$EXEDIR/def.sh"
|
||||
|
||||
getuser
|
||||
|
||||
"$EXEDIR/create_ipset.sh"
|
6
ipset/zapret-hosts-user-exclude.txt
Normal file
6
ipset/zapret-hosts-user-exclude.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
10.0.0.0/8
|
||||
172.16.0.0/12
|
||||
192.168.0.0/16
|
||||
169.254.0.0/16
|
||||
fc00::/7
|
||||
fe80::/10
|
2
ipset/zapret-hosts-user-ipban.txt
Normal file
2
ipset/zapret-hosts-user-ipban.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
kinozal.tv
|
||||
rutracker.org
|
3
ipset/zapret-hosts-user.txt
Normal file
3
ipset/zapret-hosts-user.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
st.kinozal.tv
|
||||
s.kinozal.tv
|
||||
putinhuylo.com
|
Reference in New Issue
Block a user