forked from tas-unn/bypass_keenetic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_unblock_ipset.sh
34 lines (23 loc) · 1015 Bytes
/
add_unblock_ipset.sh
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
# unblockvpn - множество
# vpn1.txt - название файла со списком обхода
while read -r line || [ -n "$line" ]; do
[ -z "$line" ] && continue
#[ "${line:0:1}" = "#" ] && continue
[ "${line#?}" = "#" ] && continue
cidr=$(echo "$line" | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}')
if [ -n "$cidr" ]; then
ipset -exist add unblockvpn "$cidr"
continue
fi
range=$(echo "$line" | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}-[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
if [ -n "$range" ]; then
ipset -exist add unblockvpn "$range"
continue
fi
addr=$(echo "$line" | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
if [ -n "$addr" ]; then
ipset -exist add unblockvpn "$addr"
continue
fi
dig +short "$line" @localhost -p 40500 | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | awk '{system("ipset -exist add unblockvpn "$1)}'
done < /opt/etc/unblock/vpn1.txt