-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
145 lines (123 loc) · 4.31 KB
/
main.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/sh
RED="\033[31m"
GREEN="\033[32m"
YELLOW="\033[33m"
PLAIN='\033[0m'
red(){
echo -e "\033[31m\033[01m$1\033[0m"
}
green(){
echo -e "\033[32m\033[01m$1\033[0m"
}
yellow(){
echo -e "\033[33m\033[01m$1\033[0m"
}
rm -f warp.conf proxy.conf
chmod +x ./warp-go ./warp-api
clear
yellow "请选择需要使用的 WARP 账户类型"
echo ""
echo -e " ${GREEN}1.${PLAIN} WARP 免费账户 ${YELLOW}(默认)${PLAIN}"
echo -e " ${GREEN}2.${PLAIN} WARP+"
echo -e " ${GREEN}3.${PLAIN} WARP Teams"
echo ""
read -p "请输入选项 [1-3]: " account_type
if [[ $account_type == 2 ]]; then
yellow "获取 CloudFlare WARP 账号密钥信息方法: "
green "电脑: 下载并安装 CloudFlare WARP → 设置 → 偏好设置 → 账户 →复制密钥到脚本中"
green "手机: 下载并安装 1.1.1.1 APP → 菜单 → 账户 → 复制密钥到脚本中"
echo ""
yellow "重要:请确保手机或电脑的 1.1.1.1 APP 的账户状态为WARP+!"
echo ""
read -rp "输入 WARP 账户许可证密钥 (26个字符): " warpkey
until [[ $warpkey =~ ^[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}-[A-Z0-9a-z]{8}$ ]]; do
red "WARP 账户许可证密钥格式输入错误,请重新输入!"
read -rp "输入 WARP 账户许可证密钥 (26个字符): " warpkey
done
read -rp "请输入自定义设备名,如未输入则使用默认随机设备名: " device_name
[[ -z $device_name ]] && device_name=$(date +%s%N | md5sum | cut -c 1-6)
result_output=$(./warp-api)
device_id=$(echo "$result_output" | awk -F ': ' '/device_id/{print $2}')
private_key=$(echo "$result_output" | awk -F ': ' '/private_key/{print $2}')
warp_token=$(echo "$result_output" | awk -F ': ' '/token/{print $2}')
cat << EOF > warp.conf
[Account]
Device = $device_id
PrivateKey = $private_key
Token = $warp_token
Type = free
Name = WARP
MTU = 1280
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
Endpoint = 162.159.192.8:0
Endpoint6 = [2606:4700:d0::a29f:c008]:0
# AllowedIPs = 0.0.0.0/0
# AllowedIPs = ::/0
KeepAlive = 30
EOF
./warp-go --update --config=./warp.conf --license=$warpkey --device-name=$device_name
elif [[ $account_type == 3 ]]; then
yellow "请在此网站:https://web--public--warp-team-api--coia-mfs4.code.run/ 获取你的 WARP Teams 账户 TOKEN"
read -rp "请输入 WARP Teams 账户的 TOKEN:" teams_token
if [[ -n $teams_token ]]; then
read -rp "请输入自定义设备名,如未输入则使用默认随机设备名: " device_name
[[ -z $device_name ]] && device_name=$(date +%s%N | md5sum | cut -c 1-6)
result_output=$(./warp-api)
device_id=$(echo "$result_output" | awk -F ': ' '/device_id/{print $2}')
private_key=$(echo "$result_output" | awk -F ': ' '/private_key/{print $2}')
warp_token=$(echo "$result_output" | awk -F ': ' '/token/{print $2}')
cat << EOF > warp.conf
[Account]
Device = $device_id
PrivateKey = $private_key
Token = $warp_token
Type = free
Name = WARP
MTU = 1280
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
Endpoint = 162.159.192.8:0
Endpoint6 = [2606:4700:d0::a29f:c008]:0
# AllowedIPs = 0.0.0.0/0
# AllowedIPs = ::/0
KeepAlive = 30
EOF
./warp-go --update --config=warp.conf --team-config=$teams_token --device-name=$device_name
sed -i "s/Type =.*/Type = team/g" warp.conf
else
red "未输入 WARP Teams 账户 TOKEN,脚本退出!"
exit 1
fi
else
result_output=$(./warp-api)
device_id=$(echo "$result_output" | awk -F ': ' '/device_id/{print $2}')
private_key=$(echo "$result_output" | awk -F ': ' '/private_key/{print $2}')
warp_token=$(echo "$result_output" | awk -F ': ' '/token/{print $2}')
cat << EOF > warp.conf
[Account]
Device = $device_id
PrivateKey = $private_key
Token = $warp_token
Type = free
Name = WARP
MTU = 1280
[Peer]
PublicKey = bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=
Endpoint = 162.159.192.8:0
Endpoint6 = [2606:4700:d0::a29f:c008]:0
# AllowedIPs = 0.0.0.0/0
# AllowedIPs = ::/0
KeepAlive = 30
EOF
fi
./warp-go --config=warp.conf --export-wireguard=proxy.conf
clear
green "WARP-GO 的 WireGuard 配置文件已生成成功!"
yellow "下面是配置文件内容:"
red "$(cat proxy.conf)"
echo ""
yellow "下面是配置文件分享二维码:"
qrencode -t ansiutf8 < proxy.conf
echo ""
yellow "请在本地使用此方法:https://blog.misaka.rest/2023/03/12/cf-warp-yxip/ 优选可用的 Endpoint IP"