
Shell
x
9
1
#
2
mkdir $HOME/.wgcf
3
cd !$
4
wget git.io/warp.sh && chmod +x warp.sh
5
mv ../wgcf-* .
6
./warp.sh wgd # ipv4和ipv6都变成wireguard
7
# 有问题就重启一遍
8
warp.sh retart
9
Contents
hide
比较 – 之前和之后
git.io/warp.sh 源代码

Shell
xxxxxxxxxx
1
1333
1333
1
2
#
3
# https://github.com/P3TERX/warp.sh
4
# Description: Cloudflare WARP configuration script
5
# System Required: Debian, Ubuntu, CentOS
6
# Version: beta17
7
#
8
# MIT License
9
#
10
# Copyright (c) 2021 P3TERX <https://p3terx.com>
11
#
12
# Permission is hereby granted, free of charge, to any person obtaining a copy
13
# of this software and associated documentation files (the "Software"), to deal
14
# in the Software without restriction, including without limitation the rights
15
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
# copies of the Software, and to permit persons to whom the Software is
17
# furnished to do so, subject to the following conditions:
18
#
19
# The above copyright notice and this permission notice shall be included in all
20
# copies or substantial portions of the Software.
21
#
22
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
# SOFTWARE.
29
#
30
31
shVersion='beta17'
32
33
FontColor_Red="\033[31m"
34
FontColor_Red_Bold="\033[1;31m"
35
FontColor_Green="\033[32m"
36
FontColor_Green_Bold="\033[1;32m"
37
FontColor_Yellow="\033[33m"
38
FontColor_Yellow_Bold="\033[1;33m"
39
FontColor_Purple="\033[35m"
40
FontColor_Purple_Bold="\033[1;35m"
41
FontColor_Suffix="\033[0m"
42
43
log() {
44
local LEVEL="$1"
45
local MSG="$2"
46
case "${LEVEL}" in
47
INFO)
48
local LEVEL="[${FontColor_Green}${LEVEL}${FontColor_Suffix}]"
49
local MSG="${LEVEL} ${MSG}"
50
;;
51
WARN)
52
local LEVEL="[${FontColor_Yellow}${LEVEL}${FontColor_Suffix}]"
53
local MSG="${LEVEL} ${MSG}"
54
;;
55
ERROR)
56
local LEVEL="[${FontColor_Red}${LEVEL}${FontColor_Suffix}]"
57
local MSG="${LEVEL} ${MSG}"
58
;;
59
*) ;;
60
esac
61
echo -e "${MSG}"
62
}
63
64
if [[ $(uname -s) != Linux ]]; then
65
log ERROR "This operating system is not supported."
66
exit 1
67
fi
68
69
if [[ $(id -u) != 0 ]]; then
70
log ERROR "This script must be run as root."
71
exit 1
72
fi
73
74
if [[ -z $(command -v curl) ]]; then
75
log ERROR "cURL is not installed."
76
exit 1
77
fi
78
79
OS_ID=$(cat /etc/os-release | grep ^ID=)
80
WireGuard_table='51888'
81
WireGuard_fwmark='51888'
82
WireGuard_Interface='wgcf'
83
WireGuardConfPath="/etc/wireguard/${WireGuard_Interface}.conf"
84
WGCF_Profile='wgcf-profile.conf'
85
WGCF_SavePath="${HOME}/.wgcf"
86
WGCF_Profile_Path="${WGCF_SavePath}/${WGCF_Profile}"
87
WGCF_DNS_IPv4='8.8.8.8,8.8.4.4'
88
WGCF_DNS_IPv6='2001:4860:4860::8888,2001:4860:4860::8844'
89
WGCF_DNS_46="${WGCF_DNS_IPv4},${WGCF_DNS_IPv6}"
90
WGCF_DNS_64="${WGCF_DNS_IPv6},${WGCF_DNS_IPv4}"
91
WGCF_Endpoint_IP4='162.159.192.1'
92
WGCF_Endpoint_IP6='2606:4700:d0::a29f:c001'
93
WGCF_Endpoint_IPv4="${WGCF_Endpoint_IP4}:2408"
94
WGCF_Endpoint_IPv6="[${WGCF_Endpoint_IP6}]:2408"
95
WGCF_Endpoint_Domain='engage.cloudflareclient.com:2408'
96
WGCF_AllowedIPs_IPv4='0.0.0.0/0'
97
WGCF_AllowedIPs_IPv6='::/0'
98
WGCF_AllowedIPs_DualStack='0.0.0.0/0,::/0'
99
TestIPv4_1='8.8.8.8'
100
TestIPv4_2='9.9.9.9'
101
TestIPv6_1='2001:4860:4860::8888'
102
TestIPv6_2='2620:fe::fe'
103
CF_Trace_URL='https://www.cloudflare.com/cdn-cgi/trace'
104
105
Install_Requirements_Debian() {
106
if [[ ! $(command -v lsb_release) ]]; then
107
apt update
108
apt install lsb-release -y
109
fi
110
if [[ ! $(command -v gpg) ]]; then
111
apt update
112
apt install gnupg -y
113
fi
114
if [[ ! $(apt list 2>/dev/null | grep apt-transport-https | grep installed) ]]; then
115
apt update
116
apt install apt-transport-https -y
117
fi
118
}
119
120
Instal_WARP_Client_Debian() {
121
Install_Requirements_Debian
122
curl https://pkg.cloudflareclient.com/pubkey.gpg | apt-key add -
123
echo "deb http://pkg.cloudflareclient.com/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/cloudflare-client.list
124
apt update
125
apt install cloudflare-warp -y
126
}
127
128
Instal_WARP_Client_Ubuntu() {
129
Install_Requirements_Debian
130
curl https://pkg.cloudflareclient.com/pubkey.gpg | apt-key add -
131
#echo "deb http://pkg.cloudflareclient.com/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/cloudflare-client.list
132
echo "deb http://pkg.cloudflareclient.com/ focal main" | tee /etc/apt/sources.list.d/cloudflare-client.list
133
apt update
134
apt install cloudflare-warp -y
135
}
136
137
Instal_WARP_Client_CentOS() {
138
CentOS_Version=$(cat /etc/redhat-release | sed -r 's/.* ([0-9]+)\..*/\1/')
139
rpm -ivh http://pkg.cloudflareclient.com/cloudflare-release-el${CentOS_Version}.rpm
140
if [[ $? = 0 ]]; then
141
yum install cloudflare-warp -y
142
else
143
log ERROR "This operating system is not supported."
144
exit 1
145
fi
146
}
147
148
Check_WARP_Client() {
149
WARP_Client_Status=$(systemctl is-active warp-svc)
150
WARP_Client_SelfStart=$(systemctl is-enabled warp-svc 2>/dev/null)
151
}
152
153
Instal_WARP_Client() {
154
log INFO "Installing Cloudflare WARP Client..."
155
case ${OS_ID} in
156
*debian*)
157
Instal_WARP_Client_Debian
158
;;
159
*ubuntu*)
160
Instal_WARP_Client_Ubuntu
161
;;
162
*centos* | *rhel*)
163
Instal_WARP_Client_CentOS
164
;;
165
*)
166
log ERROR "This operating system is not supported."
167
exit 1
168
;;
169
esac
170
Check_WARP_Client
171
if [[ ${WARP_Client_Status} = active ]]; then
172
log INFO "Cloudflare WARP Client installed successfully!"
173
else
174
log ERROR "warp-svc failure to run!"
175
journalctl -u warp-svc --no-pager
176
exit 1
177
fi
178
}
179
180
Uninstall_WARP_Client() {
181
log INFO "Uninstalling Cloudflare WARP Client..."
182
case ${OS_ID} in
183
*debian* | *ubuntu*)
184
apt purge cloudflare-warp -y
185
;;
186
*centos* | *rhel*)
187
yum remove cloudflare-warp -y
188
;;
189
*)
190
log ERROR "This operating system is not supported."
191
exit 1
192
;;
193
esac
194
}
195
196
Restart_WARP_Client() {
197
log INFO "Restarting Cloudflare WARP Client..."
198
systemctl restart warp-svc
199
Check_WARP_Client
200
if [[ ${WARP_Client_Status} = active ]]; then
201
log INFO "Cloudflare WARP Client has been restarted."
202
else
203
log ERROR "Cloudflare WARP Client failure to run!"
204
journalctl -u warp-svc --no-pager
205
exit 1
206
fi
207
}
208
209
Init_WARP_Client() {
210
Check_WARP_Client
211
if [[ ${WARP_Client_SelfStart} != enabled || ${WARP_Client_Status} != active ]]; then
212
Instal_WARP_Client
213
fi
214
yes | warp-cli
215
if [[ $(warp-cli account) = MissingRegistration ]]; then
216
log INFO "Cloudflare WARP Account Registration in progress..."
217
warp-cli register
218
fi
219
}
220
221
Connect_WARP() {
222
log INFO "Connecting to WARP..."
223
warp-cli connect
224
log INFO "Enable WARP Always-On..."
225
warp-cli enable-always-on
226
}
227
228
Disconnect_WARP() {
229
log INFO "Disable WARP Always-On..."
230
warp-cli disable-always-on
231
log INFO "Disconnect from WARP..."
232
warp-cli disconnect
233
}
234
235
Set_WARP_Mode_Proxy() {
236
log INFO "Setting up WARP Proxy Mode..."
237
warp-cli set-mode proxy
238
}
239
240
Enable_WARP_Client_Proxy() {
241
Init_WARP_Client
242
Set_WARP_Mode_Proxy
243
Connect_WARP
244
Print_WARP_Client_Status
245
}
246
247
Get_WARP_Proxy_Port() {
248
WARP_Proxy_Port='40000'
249
}
250
251
Print_Delimiter() {
252
printf '=%.0s' $(seq $(tput cols))
253
echo
254
}
255
256
Install_wgcf() {
257
curl -fsSL git.io/wgcf.sh | bash
258
}
259
260
Uninstall_wgcf() {
261
rm -f /usr/local/bin/wgcf
262
}
263
264
Register_WARP_Account() {
265
while [[ ! -f wgcf-account.toml ]]; do
266
Install_wgcf
267
log INFO "Cloudflare WARP Account registration in progress..."
268
yes | wgcf register
269
sleep 5
270
done
271
}
272
273
Generate_WGCF_Profile() {
274
while [[ ! -f ${WGCF_Profile} ]]; do
275
Register_WARP_Account
276
log INFO "WARP WireGuard profile (wgcf-profile.conf) generation in progress..."
277
wgcf generate
278
done
279
}
280
281
Backup_WGCF_Profile() {
282
mkdir -p ${WGCF_SavePath}
283
mv -f wgcf* ${WGCF_SavePath}
284
}
285
286
Read_WGCF_Profile() {
287
WGCF_PrivateKey=$(cat ${WGCF_Profile_Path} | grep ^PrivateKey | cut -d= -f2- | awk '$1=$1')
288
WGCF_Address=$(cat ${WGCF_Profile_Path} | grep ^Address | cut -d= -f2- | awk '$1=$1' | sed ":a;N;s/\n/,/g;ta")
289
WGCF_PublicKey=$(cat ${WGCF_Profile_Path} | grep ^PublicKey | cut -d= -f2- | awk '$1=$1')
290
WGCF_Address_IPv4=$(echo ${WGCF_Address} | cut -d, -f1 | cut -d'/' -f1)
291
WGCF_Address_IPv6=$(echo ${WGCF_Address} | cut -d, -f2 | cut -d'/' -f1)
292
}
293
294
Load_WGCF_Profile() {
295
if [[ -f ${WGCF_Profile} ]]; then
296
Backup_WGCF_Profile
297
Read_WGCF_Profile
298
elif [[ -f ${WGCF_Profile_Path} ]]; then
299
Read_WGCF_Profile
300
else
301
Generate_WGCF_Profile
302
Backup_WGCF_Profile
303
Read_WGCF_Profile
304
fi
305
}
306
307
Install_WireGuardTools_Debian() {
308
if [[ ! $(command -v lsb_release) ]]; then
309
apt update
310
apt install lsb-release -y
311
fi
312
DebianVer=$(lsb_release -sr | cut -d. -f1)
313
case ${DebianVer} in
314
10)
315
if [[ -z $(grep "^deb.*buster-backports.*main" /etc/apt/sources.list{,.d/*}) ]]; then
316
echo "deb http://deb.debian.org/debian buster-backports main" | tee /etc/apt/sources.list.d/backports.list
317
fi
318
;;
319
9)
320
if [[ -z $(grep "^deb.*unstable.*main" /etc/apt/sources.list{,.d/*}) ]]; then
321
echo "deb http://deb.debian.org/debian/ unstable main" | tee /etc/apt/sources.list.d/unstable.list
322
echo -e "Package: *\nPin: release a=unstable\nPin-Priority: 150\n" | tee /etc/apt/preferences.d/limit-unstable
323
fi
324
;;
325
*)
326
if [[ ${DebianVer} -lt 9 ]]; then
327
log ERROR "This operating system is not supported."
328
exit 1
329
fi
330
;;
331
esac
332
apt update
333
apt install iproute2 openresolv -y
334
apt install wireguard-tools --no-install-recommends -y
335
}
336
337
Install_WireGuardTools_Ubuntu() {
338
apt update
339
apt install iproute2 openresolv -y
340
apt install wireguard-tools --no-install-recommends -y
341
}
342
343
Install_WireGuardTools_CentOS() {
344
yum install epel-release -y
345
yum install iproute wireguard-tools -y
346
}
347
348
Install_WireGuardTools_Fedora() {
349
dnf install iproute openresolv wireguard-tools -y
350
chmod +x /usr/sbin/resolvconf.openresolv
351
}
352
353
Install_WireGuardTools_Arch() {
354
pacman -Sy iproute2 openresolv wireguard-tools --noconfirm
355
}
356
357
Install_WireGuardTools() {
358
log INFO "Installing wireguard-tools..."
359
case ${OS_ID} in
360
*debian*)
361
Install_WireGuardTools_Debian
362
;;
363
*ubuntu*)
364
Install_WireGuardTools_Ubuntu
365
;;
366
*centos* | *rhel*)
367
Install_WireGuardTools_CentOS
368
;;
369
*fedora*)
370
Install_WireGuardTools_Fedora
371
;;
372
*arch*)
373
Install_WireGuardTools_Arch
374
;;
375
*)
376
log ERROR "This operating system is not supported."
377
exit 1
378
;;
379
esac
380
}
381
382
Install_WireGuardGo() {
383
KernelVer1=$(uname -r | awk -F . '{print $1}')
384
KernelVer2=$(uname -r | awk -F . '{print $2}')
385
if [[ ${KernelVer1} -lt 5 || ${KernelVer2} -lt 6 ]]; then
386
curl -fsSL git.io/wireguard-go.sh | bash
387
fi
388
}
389
390
Check_WireGuard() {
391
WireGuard_Status=$(systemctl is-active wg-quick@${WireGuard_Interface})
392
WireGuard_SelfStart=$(systemctl is-enabled wg-quick@${WireGuard_Interface} 2>/dev/null)
393
}
394
395
Install_WireGuard() {
396
Check_WireGuard
397
if [[ ${WireGuard_SelfStart} != enabled || ${WireGuard_Status} != active ]]; then
398
Install_WireGuardTools
399
Install_WireGuardGo
400
fi
401
}
402
403
Start_WireGuard() {
404
Check_WARP_Client
405
log INFO "Starting WireGuard..."
406
if [[ ${WARP_Client_Status} = active ]]; then
407
systemctl stop warp-svc
408
systemctl enable wg-quick@${WireGuard_Interface} --now
409
systemctl start warp-svc
410
else
411
systemctl enable wg-quick@${WireGuard_Interface} --now
412
fi
413
Check_WireGuard
414
if [[ ${WireGuard_Status} = active ]]; then
415
log INFO "WireGuard is running."
416
else
417
log ERROR "WireGuard failure to run!"
418
journalctl -u wg-quick@${WireGuard_Interface} --no-pager
419
exit 1
420
fi
421
}
422
423
Restart_WireGuard() {
424
Check_WARP_Client
425
log INFO "Restarting WireGuard..."
426
if [[ ${WARP_Client_Status} = active ]]; then
427
systemctl stop warp-svc
428
systemctl restart wg-quick@${WireGuard_Interface}
429
systemctl start warp-svc
430
else
431
systemctl restart wg-quick@${WireGuard_Interface}
432
fi
433
Check_WireGuard
434
if [[ ${WireGuard_Status} = active ]]; then
435
log INFO "WireGuard has been restarted."
436
else
437
log ERROR "WireGuard failure to run!"
438
journalctl -u wg-quick@${WireGuard_Interface} --no-pager
439
exit 1
440
fi
441
}
442
443
Enable_IPv6_Support() {
444
if [[ $(sysctl -a | grep 'disable_ipv6.*=.*1') || $(cat /etc/sysctl.{conf,d/*} | grep 'disable_ipv6.*=.*1') ]]; then
445
sed -i '/disable_ipv6/d' /etc/sysctl.{conf,d/*}
446
echo 'net.ipv6.conf.all.disable_ipv6 = 0' >/etc/sysctl.d/ipv6.conf
447
sysctl -w net.ipv6.conf.all.disable_ipv6=0
448
fi
449
}
450
451
Enable_WireGuard() {
452
Enable_IPv6_Support
453
Check_WireGuard
454
if [[ ${WireGuard_SelfStart} = enabled ]]; then
455
Restart_WireGuard
456
else
457
Start_WireGuard
458
fi
459
}
460
461
Stop_WireGuard() {
462
Check_WARP_Client
463
if [[ ${WireGuard_Status} = active ]]; then
464
log INFO "Stoping WireGuard..."
465
if [[ ${WARP_Client_Status} = active ]]; then
466
systemctl stop warp-svc
467
systemctl stop wg-quick@${WireGuard_Interface}
468
systemctl start warp-svc
469
else
470
systemctl stop wg-quick@${WireGuard_Interface}
471
fi
472
Check_WireGuard
473
if [[ ${WireGuard_Status} != active ]]; then
474
log INFO "WireGuard has been stopped."
475
else
476
log ERROR "WireGuard stop failure!"
477
fi
478
else
479
log INFO "WireGuard is stopped."
480
fi
481
}
482
483
Disable_WireGuard() {
484
Check_WARP_Client
485
Check_WireGuard
486
if [[ ${WireGuard_SelfStart} = enabled || ${WireGuard_Status} = active ]]; then
487
log INFO "Disabling WireGuard..."
488
if [[ ${WARP_Client_Status} = active ]]; then
489
systemctl stop warp-svc
490
systemctl disable wg-quick@${WireGuard_Interface} --now
491
systemctl start warp-svc
492
else
493
systemctl disable wg-quick@${WireGuard_Interface} --now
494
fi
495
Check_WireGuard
496
if [[ ${WireGuard_SelfStart} != enabled && ${WireGuard_Status} != active ]]; then
497
log INFO "Wireguard has been disabled."
498
else
499
log ERROR "WireGuard disable failure!"
500
fi
501
else
502
log INFO "WireGuard is disabled."
503
fi
504
}
505
506
Print_WireGuard_Log() {
507
journalctl -u wg-quick@${WireGuard_Interface} -f
508
}
509
510
Check_Network_Status_IPv4() {
511
if ping -c1 -W1 ${TestIPv4_1} >/dev/null 2>&1 || ping -c1 -W1 ${TestIPv4_2} >/dev/null 2>&1; then
512
IPv4Status='on'
513
else
514
IPv4Status='off'
515
fi
516
}
517
518
Check_Network_Status_IPv6() {
519
if ping6 -c1 -W1 ${TestIPv6_1} >/dev/null 2>&1 || ping6 -c1 -W1 ${TestIPv6_2} >/dev/null 2>&1; then
520
IPv6Status='on'
521
else
522
IPv6Status='off'
523
fi
524
}
525
526
Check_Network_Status() {
527
Disable_WireGuard
528
Check_Network_Status_IPv4
529
Check_Network_Status_IPv6
530
}
531
532
Check_IPv4_addr() {
533
IPv4_addr=$(
534
ip route get ${TestIPv4_1} 2>/dev/null | grep -oP 'src \K\S+' ||
535
ip route get ${TestIPv4_2} 2>/dev/null | grep -oP 'src \K\S+'
536
)
537
}
538
539
Check_IPv6_addr() {
540
IPv6_addr=$(
541
ip route get ${TestIPv6_1} 2>/dev/null | grep -oP 'src \K\S+' ||
542
ip route get ${TestIPv6_2} 2>/dev/null | grep -oP 'src \K\S+'
543
)
544
}
545
546
Get_IP_addr() {
547
Check_Network_Status
548
if [[ ${IPv4Status} = on ]]; then
549
log INFO "Checking IPv4 Address..."
550
Check_IPv4_addr
551
if [[ ${IPv4_addr} ]]; then
552
log INFO "IPv4 Address: ${FontColor_Purple}${IPv4_addr}${FontColor_Suffix}"
553
else
554
log WARN "IPv4 Address not obtained."
555
fi
556
fi
557
if [[ ${IPv6Status} = on ]]; then
558
log INFO "Checking IPv6 Address..."
559
Check_IPv6_addr
560
if [[ ${IPv6_addr} ]]; then
561
log INFO "IPv6 Address: ${FontColor_Purple}${IPv6_addr}${FontColor_Suffix}"
562
else
563
log WARN "IPv6 Address not obtained."
564
fi
565
fi
566
}
567
568
Get_IPv4_addr() {
569
log INFO "正在检测 IPv4 地址..."
570
Check_IPv4_addr
571
if [[ -z ${IPv4_addr} ]]; then
572
log ERROR "IPv4 地址自动检测失败!"
573
Input_IPv4_addr
574
else
575
log INFO "检测到 IPv4 地址:${FontColor_Purple}${IPv4_addr}${FontColor_Suffix}"
576
unset answer_YN
577
read -p "是否需要修改?[y/N] " answer_YN
578
case ${answer_YN:-n} in
579
Y | y)
580
Input_IPv4_addr
581
;;
582
N | n)
583
echo
584
;;
585
*)
586
log ERROR "无效输入!"
587
Get_IPv4_addr
588
;;
589
esac
590
fi
591
}
592
593
Get_IPv6_addr() {
594
log INFO "正在检测 IPv6 地址..."
595
Check_IPv6_addr
596
if [[ -z ${IPv6_addr} ]]; then
597
log ERROR "IPv6 地址自动检测失败!"
598
Input_IPv6_addr
599
else
600
log INFO "检测到 IPv6 地址:${FontColor_Purple}${IPv6_addr}${FontColor_Suffix}"
601
unset answer_YN
602
read -p "是否需要修改?[y/N] " answer_YN
603
case ${answer_YN:-n} in
604
Y | y)
605
Input_IPv6_addr
606
;;
607
N | n)
608
echo
609
;;
610
*)
611
log ERROR "无效输入!"
612
Get_IPv6_addr
613
;;
614
esac
615
fi
616
}
617
618
Input_IPv4_addr() {
619
read -p "请输入 IPv4 地址:" IPv4_addr
620
if [[ -z ${IPv4_addr} ]]; then
621
log ERROR "无效输入!"
622
Get_IPv4_addr
623
fi
624
}
625
626
Input_IPv6_addr() {
627
read -p "请输入 IPv6 地址:" IPv6_addr
628
if [[ -z ${IPv6_addr} ]]; then
629
log ERROR "无效输入!"
630
Get_IPv6_addr
631
fi
632
}
633
634
Generate_WireGuardProfile_Interface() {
635
log INFO "WireGuard profile (${WireGuardConfPath}) generation in progress..."
636
cat <<EOF >${WireGuardConfPath}
637
[Interface]
638
PrivateKey = ${WGCF_PrivateKey}
639
Address = ${WGCF_Address}
640
DNS = ${WGCF_DNS}
641
MTU = 1280
642
EOF
643
}
644
645
Generate_WireGuardProfile_Interface_Rule_TableOff() {
646
cat <<EOF >>${WireGuardConfPath}
647
Table = off
648
EOF
649
}
650
651
Generate_WireGuardProfile_Interface_Rule_IPv4_nonGlobal() {
652
cat <<EOF >>${WireGuardConfPath}
653
PostUP = ip -4 route add default dev ${WireGuard_Interface} table ${WireGuard_table}
654
PostUP = ip -4 rule add from ${WGCF_Address_IPv4} lookup ${WireGuard_table}
655
PostDown = ip -4 rule delete from ${WGCF_Address_IPv4} lookup ${WireGuard_table}
656
PostUP = ip -4 rule add fwmark ${WireGuard_fwmark} lookup ${WireGuard_table}
657
PostDown = ip -4 rule delete fwmark ${WireGuard_fwmark} lookup ${WireGuard_table}
658
PostUP = ip -4 rule add table main suppress_prefixlength 0
659
PostDown = ip -4 rule delete table main suppress_prefixlength 0
660
EOF
661
}
662
663
Generate_WireGuardProfile_Interface_Rule_IPv6_nonGlobal() {
664
cat <<EOF >>${WireGuardConfPath}
665
PostUP = ip -6 route add default dev ${WireGuard_Interface} table ${WireGuard_table}
666
PostUP = ip -6 rule add from ${WGCF_Address_IPv6} lookup ${WireGuard_table}
667
PostDown = ip -6 rule delete from ${WGCF_Address_IPv6} lookup ${WireGuard_table}
668
PostUP = ip -6 rule add fwmark ${WireGuard_fwmark} lookup ${WireGuard_table}
669
PostDown = ip -6 rule delete fwmark ${WireGuard_fwmark} lookup ${WireGuard_table}
670
PostUP = ip -6 rule add table main suppress_prefixlength 0
671
PostDown = ip -6 rule delete table main suppress_prefixlength 0
672
EOF
673
}
674
675
Generate_WireGuardProfile_Interface_Rule_DualStack_nonGlobal() {
676
Generate_WireGuardProfile_Interface_Rule_TableOff
677
Generate_WireGuardProfile_Interface_Rule_IPv4_nonGlobal
678
Generate_WireGuardProfile_Interface_Rule_IPv6_nonGlobal
679
}
680
681
Generate_WireGuardProfile_Interface_Rule_IPv4_Global_srcIP() {
682
cat <<EOF >>${WireGuardConfPath}
683
PostUp = ip -4 rule add from ${IPv4_addr} lookup main prio 18
684
PostDown = ip -4 rule delete from ${IPv4_addr} lookup main prio 18
685
EOF
686
}
687
688
Generate_WireGuardProfile_Interface_Rule_IPv6_Global_srcIP() {
689
cat <<EOF >>${WireGuardConfPath}
690
PostUp = ip -6 rule add from ${IPv6_addr} lookup main prio 18
691
PostDown = ip -6 rule delete from ${IPv6_addr} lookup main prio 18
692
EOF
693
}
694
695
Generate_WireGuardProfile_Peer() {
696
cat <<EOF >>${WireGuardConfPath}
697
[Peer]
698
PublicKey = ${WGCF_PublicKey}
699
AllowedIPs = ${WGCF_AllowedIPs}
700
Endpoint = ${WGCF_Endpoint}
701
EOF
702
}
703
704
Check_WARP_Client_Status() {
705
Check_WARP_Client
706
case ${WARP_Client_Status} in
707
active)
708
WARP_Client_Status_en="${FontColor_Green}Running${FontColor_Suffix}"
709
WARP_Client_Status_zh="${FontColor_Green}运行中${FontColor_Suffix}"
710
;;
711
*)
712
WARP_Client_Status_en="${FontColor_Red}Stopped${FontColor_Suffix}"
713
WARP_Client_Status_zh="${FontColor_Red}未运行${FontColor_Suffix}"
714
;;
715
esac
716
}
717
718
Check_WARP_Proxy_Status() {
719
Check_WARP_Client
720
if [[ ${WARP_Client_Status} = active ]]; then
721
Get_WARP_Proxy_Port
722
WARP_Proxy_Status=$(curl -sx "socks5h://127.0.0.1:${WARP_Proxy_Port}" ${CF_Trace_URL} --connect-timeout 2 | grep warp | cut -d= -f2)
723
else
724
unset WARP_Proxy_Status
725
fi
726
case ${WARP_Proxy_Status} in
727
on)
728
WARP_Proxy_Status_en="${FontColor_Green}${WARP_Proxy_Port}${FontColor_Suffix}"
729
WARP_Proxy_Status_zh="${WARP_Proxy_Status_en}"
730
;;
731
plus)
732
WARP_Proxy_Status_en="${FontColor_Green}${WARP_Proxy_Port}(WARP+)${FontColor_Suffix}"
733
WARP_Proxy_Status_zh="${WARP_Proxy_Status_en}"
734
;;
735
*)
736
WARP_Proxy_Status_en="${FontColor_Red}Off${FontColor_Suffix}"
737
WARP_Proxy_Status_zh="${FontColor_Red}未开启${FontColor_Suffix}"
738
;;
739
esac
740
}
741
742
Check_WireGuard_Status() {
743
Check_WireGuard
744
case ${WireGuard_Status} in
745
active)
746
WireGuard_Status_en="${FontColor_Green}Running${FontColor_Suffix}"
747
WireGuard_Status_zh="${FontColor_Green}运行中${FontColor_Suffix}"
748
;;
749
*)
750
WireGuard_Status_en="${FontColor_Red}Stopped${FontColor_Suffix}"
751
WireGuard_Status_zh="${FontColor_Red}未运行${FontColor_Suffix}"
752
;;
753
esac
754
}
755
756
Check_WARP_WireGuard_Status() {
757
Check_Network_Status_IPv4
758
if [[ ${IPv4Status} = on ]]; then
759
WARP_IPv4_Status=$(curl -s4 ${CF_Trace_URL} --connect-timeout 2 | grep warp | cut -d= -f2)
760
else
761
unset WARP_IPv4_Status
762
fi
763
case ${WARP_IPv4_Status} in
764
on)
765
WARP_IPv4_Status_en="${FontColor_Green}WARP${FontColor_Suffix}"
766
WARP_IPv4_Status_zh="${WARP_IPv4_Status_en}"
767
;;
768
plus)
769
WARP_IPv4_Status_en="${FontColor_Green}WARP+${FontColor_Suffix}"
770
WARP_IPv4_Status_zh="${WARP_IPv4_Status_en}"
771
;;
772
off)
773
WARP_IPv4_Status_en="Normal"
774
WARP_IPv4_Status_zh="正常"
775
;;
776
*)
777
Check_Network_Status_IPv4
778
if [[ ${IPv4Status} = on ]]; then
779
WARP_IPv4_Status_en="Normal"
780
WARP_IPv4_Status_zh="正常"
781
else
782
WARP_IPv4_Status_en="${FontColor_Red}Unconnected${FontColor_Suffix}"
783
WARP_IPv4_Status_zh="${FontColor_Red}未连接${FontColor_Suffix}"
784
fi
785
;;
786
esac
787
Check_Network_Status_IPv6
788
if [[ ${IPv6Status} = on ]]; then
789
WARP_IPv6_Status=$(curl -s6 ${CF_Trace_URL} --connect-timeout 2 | grep warp | cut -d= -f2)
790
else
791
unset WARP_IPv6_Status
792
fi
793
case ${WARP_IPv6_Status} in
794
on)
795
WARP_IPv6_Status_en="${FontColor_Green}WARP${FontColor_Suffix}"
796
WARP_IPv6_Status_zh="${WARP_IPv6_Status_en}"
797
;;
798
plus)
799
WARP_IPv6_Status_en="${FontColor_Green}WARP+${FontColor_Suffix}"
800
WARP_IPv6_Status_zh="${WARP_IPv6_Status_en}"
801
;;
802
off)
803
WARP_IPv6_Status_en="Normal"
804
WARP_IPv6_Status_zh="正常"
805
;;
806
*)
807
Check_Network_Status_IPv6
808
if [[ ${IPv6Status} = on ]]; then
809
WARP_IPv6_Status_en="Normal"
810
WARP_IPv6_Status_zh="正常"
811
else
812
WARP_IPv6_Status_en="${FontColor_Red}Unconnected${FontColor_Suffix}"
813
WARP_IPv6_Status_zh="${FontColor_Red}未连接${FontColor_Suffix}"
814
fi
815
;;
816
esac
817
}
818
819
Check_ALL_Status() {
820
Check_WARP_Client_Status
821
Check_WARP_Proxy_Status
822
Check_WireGuard_Status
823
Check_WARP_WireGuard_Status
824
}
825
826
Print_WARP_Client_Status() {
827
log INFO "Status check in progress..."
828
Check_WARP_Client_Status
829
Check_WARP_Proxy_Status
830
echo -e "
831
----------------------------
832
WARP Client\t: ${WARP_Client_Status_en}
833
SOCKS5 Port\t: ${WARP_Proxy_Status_en}
834
----------------------------
835
"
836
log INFO "Done."
837
}
838
839
Print_WARP_WireGuard_Status() {
840
log INFO "Status check in progress..."
841
Check_WireGuard_Status
842
Check_WARP_WireGuard_Status
843
echo -e "
844
----------------------------
845
WireGuard\t: ${WireGuard_Status_en}
846
IPv4 Network\t: ${WARP_IPv4_Status_en}
847
IPv6 Network\t: ${WARP_IPv6_Status_en}
848
----------------------------
849
"
850
log INFO "Done."
851
}
852
853
Print_ALL_Status() {
854
log INFO "Status check in progress..."
855
Check_ALL_Status
856
echo -e "
857
----------------------------
858
WARP Client\t: ${WARP_Client_Status_en}
859
SOCKS5 Port\t: ${WARP_Proxy_Status_en}
860
----------------------------
861
WireGuard\t: ${WireGuard_Status_en}
862
IPv4 Network\t: ${WARP_IPv4_Status_en}
863
IPv6 Network\t: ${WARP_IPv6_Status_en}
864
----------------------------
865
"
866
}
867
868
View_WireGuard_Profile() {
869
Print_Delimiter
870
cat ${WireGuardConfPath}
871
Print_Delimiter
872
}
873
874
Check_WGCF_Endpoint() {
875
if ping -c1 -W1 ${WGCF_Endpoint_IP4} >/dev/null 2>&1; then
876
WGCF_Endpoint="${WGCF_Endpoint_IPv4}"
877
elif ping6 -c1 -W1 ${WGCF_Endpoint_IP6} >/dev/null 2>&1; then
878
WGCF_Endpoint="${WGCF_Endpoint_IPv6}"
879
else
880
WGCF_Endpoint="${WGCF_Endpoint_Domain}"
881
fi
882
}
883
884
Set_WARP_IPv4() {
885
Install_WireGuard
886
Get_IP_addr
887
Load_WGCF_Profile
888
if [[ ${IPv4Status} = off && ${IPv6Status} = on ]]; then
889
WGCF_DNS="${WGCF_DNS_64}"
890
else
891
WGCF_DNS="${WGCF_DNS_46}"
892
fi
893
WGCF_AllowedIPs="${WGCF_AllowedIPs_IPv4}"
894
Check_WGCF_Endpoint
895
Generate_WireGuardProfile_Interface
896
if [[ -n ${IPv4_addr} ]]; then
897
Generate_WireGuardProfile_Interface_Rule_IPv4_Global_srcIP
898
fi
899
Generate_WireGuardProfile_Peer
900
View_WireGuard_Profile
901
Enable_WireGuard
902
Print_WARP_WireGuard_Status
903
}
904
905
Set_WARP_IPv6() {
906
Install_WireGuard
907
Get_IP_addr
908
Load_WGCF_Profile
909
if [[ ${IPv4Status} = off && ${IPv6Status} = on ]]; then
910
WGCF_DNS="${WGCF_DNS_64}"
911
else
912
WGCF_DNS="${WGCF_DNS_46}"
913
fi
914
WGCF_AllowedIPs="${WGCF_AllowedIPs_IPv6}"
915
Check_WGCF_Endpoint
916
Generate_WireGuardProfile_Interface
917
if [[ -n ${IPv6_addr} ]]; then
918
Generate_WireGuardProfile_Interface_Rule_IPv6_Global_srcIP
919
fi
920
Generate_WireGuardProfile_Peer
921
View_WireGuard_Profile
922
Enable_WireGuard
923
Print_WARP_WireGuard_Status
924
}
925
926
Set_WARP_DualStack() {
927
Install_WireGuard
928
Get_IP_addr
929
Load_WGCF_Profile
930
WGCF_DNS="${WGCF_DNS_46}"
931
WGCF_AllowedIPs="${WGCF_AllowedIPs_DualStack}"
932
Check_WGCF_Endpoint
933
Generate_WireGuardProfile_Interface
934
if [[ -n ${IPv4_addr} ]]; then
935
Generate_WireGuardProfile_Interface_Rule_IPv4_Global_srcIP
936
fi
937
if [[ -n ${IPv6_addr} ]]; then
938
Generate_WireGuardProfile_Interface_Rule_IPv6_Global_srcIP
939
fi
940
Generate_WireGuardProfile_Peer
941
View_WireGuard_Profile
942
Enable_WireGuard
943
Print_WARP_WireGuard_Status
944
}
945
946
Set_WARP_DualStack_nonGlobal() {
947
Install_WireGuard
948
Get_IP_addr
949
Load_WGCF_Profile
950
WGCF_DNS="${WGCF_DNS_46}"
951
WGCF_AllowedIPs="${WGCF_AllowedIPs_DualStack}"
952
Check_WGCF_Endpoint
953
Generate_WireGuardProfile_Interface
954
Generate_WireGuardProfile_Interface_Rule_DualStack_nonGlobal
955
Generate_WireGuardProfile_Peer
956
View_WireGuard_Profile
957
Enable_WireGuard
958
Print_WARP_WireGuard_Status
959
}
960
961
Add_WARP_IPv4__Change_WARP_IPv6() {
962
Install_WireGuard
963
Get_IPv6_addr
964
Load_WGCF_Profile
965
WGCF_DNS="${WGCF_DNS_64}"
966
WGCF_AllowedIPs="${WGCF_AllowedIPs_DualStack}"
967
WGCF_Endpoint="${WGCF_Endpoint_IPv6}"
968
Generate_WireGuardProfile_Interface
969
Generate_WireGuardProfile_Interface_Rule_IPv6_Global_srcIP
970
Generate_WireGuardProfile_Peer
971
View_WireGuard_Profile
972
Enable_WireGuard
973
Print_WARP_WireGuard_Status
974
}
975
976
Add_WARP_IPv6__Change_WARP_IPv4() {
977
Install_WireGuard
978
Get_IPv4_addr
979
Load_WGCF_Profile
980
WGCF_DNS="${WGCF_DNS_46}"
981
WGCF_AllowedIPs="${WGCF_AllowedIPs_DualStack}"
982
WGCF_Endpoint="${WGCF_Endpoint_IPv4}"
983
Generate_WireGuardProfile_Interface
984
Generate_WireGuardProfile_Interface_Rule_IPv4_Global_srcIP
985
Generate_WireGuardProfile_Peer
986
View_WireGuard_Profile
987
Enable_WireGuard
988
Print_WARP_WireGuard_Status
989
}
990
991
Change_WARP_IPv6() {
992
Install_WireGuard
993
Get_IPv6_addr
994
Load_WGCF_Profile
995
WGCF_DNS="${WGCF_DNS_46}"
996
WGCF_AllowedIPs="${WGCF_AllowedIPs_IPv6}"
997
WGCF_Endpoint="${WGCF_Endpoint_IPv6}"
998
Generate_WireGuardProfile_Interface
999
Generate_WireGuardProfile_Interface_Rule_IPv6_Global_srcIP
1000
Generate_WireGuardProfile_Peer
1001
View_WireGuard_Profile
1002
Enable_WireGuard
1003
Print_WARP_WireGuard_Status
1004
}
1005
1006
Change_WARP_IPv4() {
1007
Install_WireGuard
1008
Get_IPv4_addr
1009
Load_WGCF_Profile
1010
WGCF_DNS="${WGCF_DNS_64}"
1011
WGCF_AllowedIPs="${WGCF_AllowedIPs_IPv4}"
1012
WGCF_Endpoint="${WGCF_Endpoint_IPv4}"
1013
Generate_WireGuardProfile_Interface
1014
Generate_WireGuardProfile_Interface_Rule_IPv4_Global_srcIP
1015
Generate_WireGuardProfile_Peer
1016
View_WireGuard_Profile
1017
Enable_WireGuard
1018
Print_WARP_WireGuard_Status
1019
}
1020
1021
Change_WARP_DualStack_IPv4Out() {
1022
Install_WireGuard
1023
Get_IPv4_addr
1024
Get_IPv6_addr
1025
Load_WGCF_Profile
1026
WGCF_DNS="${WGCF_DNS_46}"
1027
WGCF_AllowedIPs="${WGCF_AllowedIPs_DualStack}"
1028
WGCF_Endpoint="${WGCF_Endpoint_IPv4}"
1029
Generate_WireGuardProfile_Interface
1030
Generate_WireGuardProfile_Interface_Rule_IPv4_Global_srcIP
1031
Generate_WireGuardProfile_Interface_Rule_IPv6_Global_srcIP
1032
Generate_WireGuardProfile_Peer
1033
View_WireGuard_Profile
1034
Enable_WireGuard
1035
Print_WARP_WireGuard_Status
1036
}
1037
1038
Change_WARP_DualStack_IPv6Out() {
1039
Install_WireGuard
1040
Get_IPv4_addr
1041
Get_IPv6_addr
1042
Load_WGCF_Profile
1043
WGCF_DNS="${WGCF_DNS_46}"
1044
WGCF_AllowedIPs="${WGCF_AllowedIPs_DualStack}"
1045
WGCF_Endpoint="${WGCF_Endpoint_IPv6}"
1046
Generate_WireGuardProfile_Interface
1047
Generate_WireGuardProfile_Interface_Rule_IPv4_Global_srcIP
1048
Generate_WireGuardProfile_Interface_Rule_IPv6_Global_srcIP
1049
Generate_WireGuardProfile_Peer
1050
View_WireGuard_Profile
1051
Enable_WireGuard
1052
Print_WARP_WireGuard_Status
1053
}
1054
1055
Menu_Title="${FontColor_Yellow_Bold}Cloudflare WARP 一键配置脚本${FontColor_Suffix} ${FontColor_Red}[${shVersion}]${FontColor_Suffix} by ${FontColor_Purple_Bold}P3TERX.COM${FontColor_Suffix}"
1056
1057
Menu_WARP_Client() {
1058
clear
1059
echo -e "
1060
${Menu_Title}
1061
1062
-------------------------
1063
WARP 客户端状态 : ${WARP_Client_Status_zh}
1064
SOCKS5 代理端口 : ${WARP_Proxy_Status_zh}
1065
-------------------------
1066
1067
管理 WARP 官方客户端:
1068
1069
${FontColor_Green_Bold}0${FontColor_Suffix}. 返回主菜单
1070
-
1071
${FontColor_Green_Bold}1${FontColor_Suffix}. 开启 SOCKS5 代理
1072
${FontColor_Green_Bold}2${FontColor_Suffix}. 关闭 SOCKS5 代理
1073
${FontColor_Green_Bold}3${FontColor_Suffix}. 重启 WARP 官方客户端
1074
${FontColor_Green_Bold}4${FontColor_Suffix}. 卸载 WARP 官方客户端
1075
"
1076
unset MenuNumber
1077
read -p "请输入选项: " MenuNumber
1078
echo
1079
case ${MenuNumber} in
1080
0)
1081
Start_Menu
1082
;;
1083
1)
1084
Enable_WARP_Client_Proxy
1085
;;
1086
2)
1087
Disconnect_WARP
1088
;;
1089
3)
1090
Restart_WARP_Client
1091
;;
1092
4)
1093
Uninstall_WARP_Client
1094
;;
1095
*)
1096
log ERROR "无效输入!"
1097
sleep 2s
1098
Menu_WARP_Client
1099
;;
1100
esac
1101
}
1102
1103
Menu_WARP_WireGuard_Other() {
1104
clear
1105
echo -e "
1106
${Menu_Title}
1107
1108
${FontColor_Green_Bold}0${FontColor_Suffix}. 返回主菜单
1109
-
1110
${FontColor_Green_Bold}1${FontColor_Suffix}. 置换 IPv4 为 WARP 网络
1111
${FontColor_Green_Bold}2${FontColor_Suffix}. 置换 IPv6 为 WARP 网络
1112
${FontColor_Green_Bold}3${FontColor_Suffix}. 置换 IPv4/IPv6 为 WARP 网络 (IPv4 节点)
1113
${FontColor_Green_Bold}4${FontColor_Suffix}. 置换 IPv4/IPv6 为 WARP 网络 (IPv6 节点)
1114
${FontColor_Green_Bold}5${FontColor_Suffix}. 添加 WARP IPv4 网络,置换 IPv6 为 WARP 网络
1115
${FontColor_Green_Bold}6${FontColor_Suffix}. 添加 WARP IPv6 网络,置换 IPv4 为 WARP 网络
1116
"
1117
unset MenuNumber
1118
read -p "请输入选项: " MenuNumber
1119
echo
1120
case ${MenuNumber} in
1121
0)
1122
Start_Menu
1123
;;
1124
1)
1125
Change_WARP_IPv4
1126
;;
1127
2)
1128
Change_WARP_IPv6
1129
;;
1130
3)
1131
Change_WARP_DualStack_IPv4Out
1132
;;
1133
4)
1134
Change_WARP_DualStack_IPv6Out
1135
;;
1136
5)
1137
Add_WARP_IPv4__Change_WARP_IPv6
1138
;;
1139
6)
1140
Add_WARP_IPv6__Change_WARP_IPv4
1141
;;
1142
*)
1143
log ERROR "无效输入!"
1144
sleep 2s
1145
Menu_DualStack
1146
;;
1147
esac
1148
}
1149
1150
Menu_WARP_WireGuard() {
1151
clear
1152
echo -e "
1153
${Menu_Title}
1154
1155
-------------------------
1156
WireGuard 状态 : ${WireGuard_Status_zh}
1157
IPv4 网络状态 : ${WARP_IPv4_Status_zh}
1158
IPv6 网络状态 : ${WARP_IPv6_Status_zh}
1159
-------------------------
1160
1161
管理 WARP WireGuard:
1162
1163
${FontColor_Green_Bold}0${FontColor_Suffix}. 返回主菜单
1164
-
1165
${FontColor_Green_Bold}1${FontColor_Suffix}. 查看 WARP WireGuard 日志
1166
${FontColor_Green_Bold}2${FontColor_Suffix}. 重启 WARP WireGuard 服务
1167
${FontColor_Green_Bold}3${FontColor_Suffix}. 关闭 WARP WireGuard 网络
1168
"
1169
unset MenuNumber
1170
read -p "请输入选项: " MenuNumber
1171
echo
1172
case ${MenuNumber} in
1173
0)
1174
Start_Menu
1175
;;
1176
1)
1177
Print_WireGuard_Log
1178
;;
1179
2)
1180
Restart_WireGuard
1181
;;
1182
3)
1183
Disable_WireGuard
1184
;;
1185
*)
1186
log ERROR "无效输入!"
1187
sleep 2s
1188
Menu_Other
1189
;;
1190
esac
1191
}
1192
1193
Start_Menu() {
1194
log INFO "正在检查状态..."
1195
Check_ALL_Status
1196
clear
1197
echo -e "
1198
${Menu_Title}
1199
1200
-------------------------
1201
WARP 客户端状态 : ${WARP_Client_Status_zh}
1202
SOCKS5 代理端口 : ${WARP_Proxy_Status_zh}
1203
-------------------------
1204
WireGuard 状态 : ${WireGuard_Status_zh}
1205
IPv4 网络状态 : ${WARP_IPv4_Status_zh}
1206
IPv6 网络状态 : ${WARP_IPv6_Status_zh}
1207
-------------------------
1208
1209
${FontColor_Green_Bold}1${FontColor_Suffix}. 自动配置 WARP 官方客户端 SOCKS5 代理
1210
${FontColor_Green_Bold}2${FontColor_Suffix}. 管理 WARP 官方客户端
1211
-
1212
${FontColor_Green_Bold}3${FontColor_Suffix}. 自动配置 WARP WireGuard IPv4 网络
1213
${FontColor_Green_Bold}4${FontColor_Suffix}. 自动配置 WARP WireGuard IPv6 网络
1214
${FontColor_Green_Bold}5${FontColor_Suffix}. 自动配置 WARP WireGuard 双栈全局网络
1215
${FontColor_Green_Bold}6${FontColor_Suffix}. 选择其它 WARP WireGuard 配置方案
1216
${FontColor_Green_Bold}7${FontColor_Suffix}. 管理 WARP WireGuard 网络
1217
"
1218
unset MenuNumber
1219
read -p "请输入选项: " MenuNumber
1220
echo
1221
case ${MenuNumber} in
1222
1)
1223
Enable_WARP_Client_Proxy
1224
;;
1225
2)
1226
Menu_WARP_Client
1227
;;
1228
3)
1229
Set_WARP_IPv4
1230
;;
1231
4)
1232
Set_WARP_IPv6
1233
;;
1234
5)
1235
Set_WARP_DualStack
1236
;;
1237
6)
1238
Menu_WARP_WireGuard_Other
1239
;;
1240
7)
1241
Menu_WARP_WireGuard
1242
;;
1243
*)
1244
log ERROR "无效输入!"
1245
sleep 2s
1246
Start_Menu
1247
;;
1248
esac
1249
}
1250
1251
Print_Usage() {
1252
echo -e "
1253
Cloudflare WARP configuration script
1254
1255
USAGE:
1256
bash <(curl -fsSL git.io/warp.sh) [SUBCOMMAND]
1257
1258
SUBCOMMANDS:
1259
install Install Cloudflare WARP Official Linux Client
1260
uninstall uninstall Cloudflare WARP Official Linux Client
1261
restart Restart Cloudflare WARP Official Linux Client
1262
proxy Enable WARP Client Proxy Mode (default SOCKS5 port: 40000)
1263
unproxy Disable WARP Client Proxy Mode
1264
wg Configuration WARP Non-Global Network (with WireGuard), set fwmark or interface IP Address to use the WARP network
1265
wg4 Configuration WARP IPv4 Global Network (with WireGuard), all IPv4 outbound data over the WARP network
1266
wg6 Configuration WARP IPv6 Global Network (with WireGuard), all IPv6 outbound data over the WARP network
1267
wgd Configuration WARP Dual Stack Global Network (with WireGuard), all outbound data over the WARP network
1268
rewg Restart WARP WireGuard service
1269
unwg Disable WARP WireGuard service
1270
status Prints status information
1271
version Prints version information
1272
help Prints this message or the help of the given subcommand(s)
1273
menu Chinese special features menu
1274
"
1275
}
1276
1277
if [ $# -ge 1 ]; then
1278
case ${1} in
1279
install)
1280
Instal_WARP_Client
1281
;;
1282
uninstall)
1283
Uninstall_WARP_Client
1284
;;
1285
restart)
1286
Restart_WARP_Client
1287
;;
1288
proxy | socks5 | s5)
1289
Enable_WARP_Client_Proxy
1290
;;
1291
unproxy | unsocks5 | uns5)
1292
Disconnect_WARP
1293
;;
1294
wg)
1295
Set_WARP_DualStack_nonGlobal
1296
;;
1297
wg4 | 4)
1298
Set_WARP_IPv4
1299
;;
1300
wg6 | 6)
1301
Set_WARP_IPv6
1302
;;
1303
wgd | d)
1304
Set_WARP_DualStack
1305
;;
1306
rewg)
1307
Restart_WireGuard
1308
;;
1309
unwg)
1310
Disable_WireGuard
1311
;;
1312
status)
1313
Print_ALL_Status
1314
;;
1315
help)
1316
Print_Usage
1317
;;
1318
version)
1319
echo "${shVersion}"
1320
;;
1321
menu)
1322
Start_Menu
1323
;;
1324
*)
1325
log ERROR "Invalid Parameters: $*"
1326
Print_Usage
1327
exit 1
1328
;;
1329
esac
1330
else
1331
Print_Usage
1332
fi
1333
{"mode":"full","isActive":false}