forked from tas-unn/bypass_keenetic
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
474 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/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 | ||
# | ||
# Файл: 100-unblock-vpn.sh, Версия 2.1.0, последнее изменение: 04.03.2023, 18:54 | ||
# Автор файла: NetworK (https://github.com/ziwork) | ||
|
||
check_vpn=$(curl -s localhost:79/rci/show/ip/name-server | grep service | grep -wv Dns | awk '{print $2}' | tr -d \", | sort -u) | ||
for vpn in $check_vpn ; do | ||
|
||
echo "$vpn" | ||
|
||
[ "$1" = "hook" ] || exit 0 | ||
[ "$change" = "link" ] || exit 0 | ||
[ "$id" = "$vpn" ] || exit 0 | ||
|
||
vpn_name=$vpn | ||
vpn_type=$(curl -s localhost:79/rci/show/ip/name-server | grep -wv 8.8 | grep "$vpn_name" -B5 | grep address | awk '{print $2}' | tr -d \",) | ||
vpn_ip_route=$(ip route list | grep "$vpn_type" | awk '{print $3}') | ||
|
||
IF_NAME=$vpn_ip_route | ||
IF_GW4=$(ip -4 addr show "$IF_NAME" | grep -Po "(?<=inet ).*(?=/)" | awk '{print $1}') | ||
|
||
case ${id}-${change}-${connected}-${link}-${up} in | ||
${id}-link-no-down-down) | ||
ip -4 rule del fwmark 0xd1000 lookup 1001 priority 1778 2>/dev/null | ||
ip -4 route flush table 1001 | ||
;; | ||
${id}-link-yes-up-up) | ||
ip -4 route add table 1001 default via "$IF_GW4" dev "$IF_NAME" 2>/dev/null | ||
ip -4 route show table main | grep -Ev ^default | while read -r ROUTE; do ip -4 route add table 1001 "$ROUTE" 2>/dev/null; done | ||
ip -4 rule add fwmark 0xd1000 lookup 1001 priority 1778 2>/dev/null | ||
ip -4 route flush cache | ||
;; | ||
esac | ||
|
||
done | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
if [ -z "$(iptables-save 2>/dev/null | grep unblockvpn)" ]; then | ||
ipset create unblockvpn hash:net -exist | ||
iptables -I PREROUTING -w -t nat -i br0 -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
iptables -I PREROUTING -w -t nat -i br0 -p udp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
iptables -t nat -A PREROUTING -i br0 -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
iptables -t nat -A OUTPUT -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
|
||
iptables -I PREROUTING -w -t nat -i sstp0 -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
iptables -I PREROUTING -w -t nat -i sstp0 -p udp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
iptables -t nat -A PREROUTING -i sstp0 -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
|
||
fi | ||
exit 0 | ||
# не актуальное | ||
#if [ -z "$(iptables-save 2>/dev/null | grep unblockvpn)" ]; then | ||
# ipset create unblockvpn hash:net -exist | ||
# iptables -I PREROUTING -w -t nat -i br0 -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
# iptables -I PREROUTING -w -t nat -i br0 -p udp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
# iptables -t nat -A PREROUTING -i br0 -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
# iptables -t nat -A OUTPUT -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
# | ||
# iptables -I PREROUTING -w -t nat -i sstp0 -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
# iptables -I PREROUTING -w -t nat -i sstp0 -p udp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
# iptables -t nat -A PREROUTING -i sstp0 -p tcp -m set --match-set unblockvpn dst -j MASQUERADE -o ppp1 | ||
# | ||
#fi | ||
#exit 0 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#не актуальное | ||
##vpn1 и unblockvpn меняем | ||
#while read -r line || [ -n "$line" ]; do | ||
# | ||
# [ -z "$line" ] && continue | ||
# #[ "${line:0:1}" = "#" ] && 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 < /opt/etc/unblock/vpn1.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
# 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 | ||
# не актуальное | ||
## 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 |
Oops, something went wrong.