-
Notifications
You must be signed in to change notification settings - Fork 37
/
run-boringtun.sh
91 lines (83 loc) · 3.85 KB
/
run-boringtun.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
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
#!/bin/bash
source /etc/profile
function Start {
echo -e " [Intro] One-Click Unlock Stream Media Script By Cloudflare-WARP"
echo -e " [Intro] OpenSource-Project:https://github.com/acacia233/Project-WARP-Unlock"
echo -e " [Intro] Telegram Channel:https://t.me/cutenicobest"
echo -e " [Intro] Version:2022-03-06-1"
echo -e " [Intro] Using BoringTun for better adaptability"
sleep 5
Check_System_Depandencies
}
function Check_System_Depandencies {
echo -e " [Info] Installing Depandencies..."
apt-get update >/dev/null
apt-get install -yq ipset dnsmasq resolvconf wireguard-tools mtr >/dev/null 2>&1
wget -qO /usr/bin/boringtun https://raw.githubusercontent.com/acacia233/Project-WARP-Unlock/main/boringtun
chmod +x /usr/bin/boringtun
Download_Profile
Generate_WireGuard_WARP_Profile
}
function Download_Profile {
wget -qO /etc/dnsmasq.d/warp.conf https://raw.githubusercontent.com/acacia233/Project-WARP-Unlock/main/dnsmasq/warp.conf
wget -qO /etc/wireguard/up https://raw.githubusercontent.com/acacia233/Project-WARP-Unlock/main/scripts/up
wget -qO /etc/wireguard/down https://raw.githubusercontent.com/acacia233/Project-WARP-Unlock/main/scripts/down
chmod +x /etc/wireguard/up
chmod +x /etc/wireguard/down
}
function Generate_WireGuard_WARP_Profile {
echo -e " [Info] Generating WARP Profile,Please Wait..."
wget -qO /etc/wireguard/wgcf https://github.com/ViRb3/wgcf/releases/download/v2.2.8/wgcf_2.2.8_linux_amd64
chmod +x /etc/wireguard/wgcf
/etc/wireguard/wgcf register --accept-tos --config /etc/wireguard/wgcf-account.toml >/dev/null 2>&1
sleep 10
/etc/wireguard/wgcf generate --config /etc/wireguard/wgcf-account.toml --profile /etc/wireguard/wg.conf >/dev/null 2>&1
sleep 10
sed -i '7 i Table = off' /etc/wireguard/wg.conf
sed -i '8 i PostUp = /etc/wireguard/up' /etc/wireguard/wg.conf
sed -i '9 i Predown = /etc/wireguard/down' /etc/wireguard/wg.conf
sed -i '15 i PersistentKeepalive = 5' /etc/wireguard/wg.conf
sed -i "s/engage.cloudflareclient.com/162.159.193.1/g" /etc/wireguard/wg.conf
Routing_WireGuard_WARP
}
function Routing_WireGuard_WARP {
local rt_tables_status="$(cat /etc/iproute2/rt_tables | grep warp)"
if [[ ! -n "$rt_tables_status" ]]; then
echo '250 warp' >>/etc/iproute2/rt_tables
echo -e " [Info] Creating Routing Table..."
fi
systemctl disable systemd-resolved --now >/dev/null 2>&1
sleep 2
systemctl enable dnsmasq --now >/dev/null 2>&1
sleep 2
sed -i '20 i Environment=WG_QUICK_USERSPACE_IMPLEMENTATION=boringtun WG_SUDO=1' /lib/systemd/system/[email protected]
systemctl enable wg-quick@wg --now >/dev/null 2>&1
sleep 2
systemctl restart dnsmasq >/dev/null 2>&1
echo 'nameserver 127.0.0.1' > /etc/resolv.conf
Check_finished
}
function Check_finished {
local wireguard_status="$(ip link | grep wg)"
if [[ "$wireguard_status" != *"wg"* ]]; then
echo -e " [Error] WireGuard is not Running,Restarting..."
systemctl restart wg-quick@wg
else
echo -e " [Info] WireGuard is Running,Check Connection..."
fi
local connection_status="$(ping 1.1.1.1 -I wg -c 1 2>&1)"
if [[ "$connection_status" != *"unreachable"* ]] && [[ "$connection_status" != *"Unreachable"* ]] && [[ "$connection_status" != *"SO_BINDTODEVICE"* ]] && [[ "$connection_status" != *"100% packet loss"* ]]; then
echo -e " [Info] Connection Established..."
else
echo -e " [Error] Connection Refused,Please check manually!"
exit
fi
local routing_status="$(mtr -4wn -c 1 youtube.com)"
if [[ "$routing_status" != *"172.16.0.1"* ]]; then
echo -e " [Error] Routing is not correct,Please check manually!"
else
echo -e " [Info] Routing is working normally,Enjoy~"
echo -e " [Sponsor] USDT-TRC20:TCXfFzEQ7s968s4XiWzjNGdjuuew3CzLiF"
fi
}
Start