-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathparse.patch
44 lines (36 loc) · 1.96 KB
/
parse.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--- parse.sh 2024-08-13 13:07:47.354618400 +0500
+++ parse.sh 2024-08-13 13:07:47.354618400 +0500
@@ -1,22 +1,26 @@
#!/bin/bash
set -e
-source config/config.sh
-
HERE="$(dirname "$(readlink -f "${0}")")"
cd "$HERE"
+source config/config.sh
+
# Extract domains from list
-awk -F ';' '{print $2}' temp/list.csv | sort -u | awk '/^$/ {next} /\\/ {next} /^[а-яА-Яa-zA-Z0-9\-\_\.\*]*+$/ {gsub(/\*\./, ""); gsub(/\.$/, ""); print}' | grep -Fv 'bеllonа' | CHARSET=UTF-8 idn > result/hostlist_original.txt
+if [[ $SKIP_UPDATE_FROM_ZAPRET == false ]]; then
+ awk -F ';' '{print $2}' temp/list.csv | sort -u | awk '/^$/ {next} /\\/ {next} /^[а-яА-Яa-zA-Z0-9\-_\.\*]*+$/ {gsub(/\*\./, ""); gsub(/\.$/, ""); print}' | grep -Fv 'bеllonа' | CHARSET=UTF-8 idn --no-tld | grep -Fv 'xn--' > result/hostlist_original.txt
+else
+ echo \n > result/hostlist_original.txt
+fi
# Generate zones from domains
# FIXME: nxdomain list parsing is disabled due to its instability on z-i
###cat exclude.txt temp/nxdomain.txt > temp/exclude.txt
-sort -u config/exclude-hosts-{dist,custom}.txt > temp/exclude-hosts.txt
-sort -u config/exclude-ips-{dist,custom}.txt > temp/exclude-ips.txt
-sort -u config/include-hosts-{dist,custom}.txt > temp/include-hosts.txt
-sort -u config/include-ips-{dist,custom}.txt > temp/include-ips.txt
+for file in config/custom/{include,exclude}-{hosts,ips}-custom.txt; do
+ basename=$(basename $file | sed 's|-custom.txt||')
+ sort -u $file config/${basename}-dist.txt > temp/${basename}.txt
+done
sort -u temp/include-hosts.txt result/hostlist_original.txt > temp/hostlist_original_with_include.txt
awk -F ';' '{split($1, a, /\|/); for (i in a) {print a[i]";"$2}}' temp/list.csv | \
@@ -46,6 +46,7 @@
awk -F ';' '$1 ~ /\// {print $1}' temp/list.csv | egrep -o '([0-9]{1,3}\.){3}[0-9]{1,3}\/[0-9]{1,2}' | sort -u > result/blocked-ranges.txt
+cat temp/include-ips.txt >> result/blocked-ranges.txt
# Generate OpenVPN route file
echo -n > result/openvpn-blocked-ranges.txt