ipset: use awk instead of grep to avoid wrong ip matches

This commit is contained in:
bol-van
2021-11-05 00:11:05 +03:00
parent 2bf47f4fff
commit 8adf03603c
5 changed files with 29 additions and 14 deletions

View File

@@ -10,6 +10,12 @@ ZREESTR="$TMPDIR/reestr.txt"
ZURL_REESTR=https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv
awkgrep()
{
# $1 - pattern
nice -n 5 $AWK "{while ( match(\$0,/($1[ |;])/) ) { print substr(\$0,RSTART,RLENGTH-1); \$0=substr(\$0,RSTART+RLENGTH) } }"
}
dig_reestr()
{
# $1 - grep ipmask
@@ -18,10 +24,9 @@ dig_reestr()
echo processing reestr list $2
tail -n +2 "$ZREESTR" | nice -n 5 $GREP -oE "$1" | cut_local | ip2net$3 | zz "$2"
tail -n +2 "$ZREESTR" | awkgrep "$1" | cut_local | ip2net$3 | zz "$2"
}
getuser && {
# assume all https banned by ip
curl -k --fail --max-time 600 --connect-timeout 5 --retry 3 --max-filesize 251658240 "$ZURL_REESTR" -o "$ZREESTR" ||