forked from tas-unn/bypass_keenetic
-
Notifications
You must be signed in to change notification settings - Fork 6
/
unblock.dnsmasq
100 lines (86 loc) · 4 KB
/
unblock.dnsmasq
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh
# 2023. Keenetic DNS bot / Проект: bypass_keenetic / Автор: tas_unn
# GitHub: https://github.com/tas-unn/bypass_keenetic
# Данный бот предназначен для управления обхода блокировок на роутерах Keenetic
# Демо-бот: https://t.me/keenetic_dns_bot
#
# Файл: unblock.dnsmasq, Версия 2.1.9, последнее изменение: 03.05.2023, 22:03
# Доработал: NetworK (https://github.com/ziwork)
cat /dev/null > /opt/etc/unblock.dnsmasq
#=======================================================================================
while read -r line || [ -n "$line" ]; do
[ -z "$line" ] && continue
[ "${line#?}" = "#" ] && continue
echo "$line" | grep -Eq '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && continue
host=$(echo "${line}" | sed 's/^.*\.\(.*\.\w\{2,6\}\)$/\1/')
if echo "${host}" | grep -q '\*' ; then
host=$(echo "${host}" | sed 's/\*//;') # s/\./\\./g')
#echo "ipset=/:.*${host}:/unblocksh" >> /opt/etc/unblock.dnsmasq
echo "ipset=/*.${host}/unblocksh" >> /opt/etc/unblock.dnsmasq
echo "server=/*.${host}/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
echo "ipset=/${host}/unblocksh" >> /opt/etc/unblock.dnsmasq
echo "server=/${host}/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
else
echo "ipset=/$line/unblocksh" >> /opt/etc/unblock.dnsmasq
echo "server=/$line/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
fi
done < /opt/etc/unblock/shadowsocks.txt
#=======================================================================================
#while read line || [ -n "$line" ]; do
# [ -z "$line" ] && continue
# [ "${line:0:1}" = "#" ] && continue
# echo $line | grep -Eq '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && continue
# echo "ipset=/$line/unblocksh" >> /opt/etc/unblock.dnsmasq
# echo "server=/$line/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
#done < /opt/etc/unblock/shadowsocks.txt
while read -r line || [ -n "$line" ]; do
[ -z "$line" ] && continue
[ "${line#?}" = "#" ] && continue
echo $line | grep -Eq '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && continue
echo "ipset=/$line/unblocktor" >> /opt/etc/unblock.dnsmasq
echo "server=/$line/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
done < /opt/etc/unblock/tor.txt
while read -r line || [ -n "$line" ]; do
[ -z "$line" ] && continue
[ "${line#?}" = "#" ] && continue
echo "$line" | grep -Eq '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && continue
echo "ipset=/$line/unblockvmess" >> /opt/etc/unblock.dnsmasq
echo "server=/$line/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
done < /opt/etc/unblock/vmess.txt
while read -r line || [ -n "$line" ]; do
[ -z "$line" ] && continue
[ "${line#?}" = "#" ] && continue
echo "$line" | grep -Eq '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && continue
echo "ipset=/$line/unblocktroj" >> /opt/etc/unblock.dnsmasq
echo "server=/$line/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
done < /opt/etc/unblock/trojan.txt
if ls -d /opt/etc/unblock/vpn-*.txt >/dev/null 2>&1; then
for vpn_file_names in /opt/etc/unblock/vpn-*; do
vpn_file_name=$(echo "$vpn_file_names" | awk -F '/' '{print $5}' | sed 's/.txt//')
unblockvpn=$(echo unblock"$vpn_file_name")
cat "$vpn_file_names" | while read -r line || [ -n "$line" ]; do
[ -z "$line" ] && continue
[ "${line#?}" = "#" ] && continue
echo "$line" | grep -Eq '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && continue
echo "ipset=/$line/$unblockvpn" >> /opt/etc/unblock.dnsmasq
echo "server=/$line/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
done
done
fi
#while read line || [ -n "$line" ]; do
# [ -z "$line" ] && continue
# [ "${line:0:1}" = "#" ] && continue
# echo $line | grep -Eq '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' && continue
# echo "ipset=/$line/unblockvpn" >> /opt/etc/unblock.dnsmasq
# echo "server=/$line/127.0.0.1#40500" >> /opt/etc/unblock.dnsmasq
#done < /opt/etc/unblock/vpn.txt
#script0
#script1
#script2
#script3
#script4
#script5
#script6
#script7
#script8
#script9