-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.sh
2238 lines (2021 loc) · 120 KB
/
menu.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
export LANG=en_US.UTF-8
# 当前脚本版本号
VERSION=2.46
# 选择 IP API 服务商
IP_API=https://api.ip.sb/geoip; ISP=isp
#IP_API=https://ifconfig.co/json; ISP=asn_org
#IP_API=https://ip.gs/json; ISP=asn_org
E[0]="\n Language:\n 1. English (default) \n 2. 简体中文\n"
C[0]="${E[0]}"
E[1]="Switch the IPv4 / IPv6 priority by [warp s 4/6/d]."
C[1]="通过 [warp s 4/6/d] 来切换 IPv4 / IPv6 的优先级别"
E[2]="The script must be run as root, you can enter sudo -i and then download and run again. Feedback: [https://github.com/fscarmen/warp/issues]"
C[2]="必须以root方式运行脚本,可以输入 sudo -i 后重新下载运行,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[3]="The TUN module is not loaded. You should turn it on in the control panel. Ask the supplier for more help. Feedback: [https://github.com/fscarmen/warp/issues]"
C[3]="没有加载 TUN 模块,请在管理后台开启或联系供应商了解如何开启,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[4]="The WARP server cannot be connected. It may be a China Mainland VPS. You can manually ping 162.159.193.10 or ping -6 2606:4700:d0::a29f:c001.You can run the script again if the connect is successful. Feedback: [https://github.com/fscarmen/warp/issues]"
C[4]="与 WARP 的服务器不能连接,可能是大陆 VPS,可手动 ping 162.159.193.10 或 ping -6 2606:4700:d0::a29f:c001,如能连通可再次运行脚本,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[5]="The script supports Debian, Ubuntu, CentOS, Arch or Alpine systems only. Feedback: [https://github.com/fscarmen/warp/issues]"
C[5]="本脚本只支持 Debian、Ubuntu、CentOS、Arch 或 Alpine 系统,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[6]="warp h (help)\n warp n (Get the WARP IP)\n warp o (Turn off WARP temporarily)\n warp u (Turn off and uninstall WARP interface and Socks5 Linux Client)\n warp b (Upgrade kernel, turn on BBR, change Linux system)\n warp a (Change account to Free, WARP+ or Teams)\n warp p (Getting WARP+ quota by scripts)\n warp v (Sync the latest version)\n warp r (Connect/Disconnect WARP Linux Client)\n warp 4/6 (Add WARP IPv4/IPv6 interface)\n warp d (Add WARP dualstack interface IPv4 + IPv6)\n warp c (Install WARP Linux Client and set to proxy mode)\n warp l (Install WARP Linux Client and set to WARP mode)\n warp i (Change the WARP IP to support Netflix)\n warp e (Install Iptables + dnsmasq + ipset solution)\n warp w (Install WireProxy solution)\n warp y (Connect/Disconnect WireProxy socks5)\n warp s 4/6/d (Set stack proiority: IPv4 / IPv6 / VPS default)\n"
C[6]="warp h (帮助菜单)\n warp n (获取 WARP IP)\n warp o (临时warp开关)\n warp u (卸载 WARP 网络接口和 Socks5 Client)\n warp b (升级内核、开启BBR及DD)\n warp a (更换账户为 Free,WARP+ 或 Teams)\n warp p (刷WARP+流量)\n warp v (同步脚本至最新版本)\n warp r (WARP Linux Client 开关)\n warp 4/6 (WARP IPv4/IPv6 单栈)\n warp d (WARP 双栈)\n warp c (安装 WARP Linux Client,开启 Socks5 代理模式)\n warp l (安装 WARP Linux Client,开启 WARP 模式)\n warp i (更换支持 Netflix 的IP)\n warp e (安装 Iptables + dnsmasq + ipset 解决方案)\n warp w (安装 WireProxy 解决方案)\n warp y (WireProxy socks5 开关)\n warp s 4/6/d (优先级: IPv4 / IPv6 / VPS default)\n"
E[7]="Install dependence-list:"
C[7]="安装依赖列表:"
E[8]="All dependencies already exist and do not need to be installed additionally."
C[8]="所有依赖已存在,不需要额外安装"
E[9]="Client cannot be upgraded to a Teams account."
C[9]="Client 不能升级为 Teams 账户"
E[10]="WireGuard tools are not installed or the configuration file wgcf.conf cannot be found, please reinstall."
C[10]="没有安装 WireGuard tools 或者找不到配置文件 wgcf.conf,请重新安装。"
E[11]="Maximum \${j} attempts to get WARP IP..."
C[11]="后台获取 WARP IP 中,最大尝试\${j}次……"
E[12]="Try \${i}"
C[12]="第\${i}次尝试"
E[13]="There have been more than \${j} failures. The script is aborted. Feedback: [https://github.com/fscarmen/warp/issues]"
C[13]="失败已超过\${j}次,脚本中止,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[14]="Got the WARP\$TYPE IP successfully."
C[14]="已成功获取 WARP\$TYPE 网络"
E[15]="WARP is turned off. It could be turned on again by [warp o]"
C[15]="已暂停 WARP,再次开启可以用 warp o"
E[16]="The script specifically adds WARP network interface for VPS, detailed:[https://github.com/fscarmen/warp]\n Features:\n\t • Support WARP+ account. Third-party scripts are use to increase WARP+ quota or upgrade kernel.\n\t • Not only menus, but commands with option.\n\t • Support system: Ubuntu 16.04、18.04、20.04、22.04,Debian 9、10、11,CentOS 7、8、9, Alpine, Arch Linux 3.\n\t • Support architecture: AMD,ARM and s390x\n\t • Automatically select four WireGuard solutions. Performance: Kernel with WireGuard integration > Install kernel module > wireguard-go\n\t • Intelligent analysis of the latest version of the WGCF\n\t • Suppert WARP Linux client.\n\t • Output WARP status, IP region and asn\n"
C[16]="本项目专为 VPS 添加 wgcf 网络接口,详细说明: [https://github.com/fscarmen/warp]\n 脚本特点:\n\t • 支持 WARP+ 账户,附带第三方刷 WARP+ 流量和升级内核 BBR 脚本\n\t • 普通用户友好的菜单,进阶者通过后缀选项快速搭建\n\t • 智能判断操作系统: Ubuntu 、Debian 、CentOS、 Alpine 和 Arch Linux,请务必选择 LTS 系统\n\t • 支持硬件结构类型: AMD、 ARM 和 s390x\n\t • 结合 Linux 版本和虚拟化方式,自动优选4个 WireGuard 方案。网络性能方面: 内核集成 WireGuard > 安装内核模块 > wireguard-go\n\t • 智能判断 WGCF 作者 github库的最新版本 (Latest release)\n\t • 支持 WARP Linux Socks5 Client\n\t • 输出执行结果,提示是否使用 WARP IP ,IP 归属地和线路提供商\n"
E[17]="Version"
C[17]="脚本版本"
E[18]="New features"
C[18]="功能新增"
E[19]="System infomation"
C[19]="系统信息"
E[20]="Operating System"
C[20]="当前操作系统"
E[21]="Kernel"
C[21]="内核"
E[22]="Architecture"
C[22]="处理器架构"
E[23]="Virtualization"
C[23]="虚拟化"
E[24]="Client is on"
C[24]="Client 已开启"
E[25]="Device name"
C[25]="设备名"
E[26]="Curren operating system is \$SYS.\\\n The system lower than \$SYSTEM \${MAJOR[int]} is not supported. Feedback: [https://github.com/fscarmen/warp/issues]"
C[26]="当前操作是 \$SYS\\\n 不支持 \$SYSTEM \${MAJOR[int]} 以下系统,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[27]="Local Socks5"
C[27]="本地 Socks5"
E[28]="If there is a WARP+ License, please enter it, otherwise press Enter to continue:"
C[28]="如有 WARP+ License 请输入,没有可回车继续:"
E[29]="Input errors up to 5 times.The script is aborted."
C[29]="输入错误达5次,脚本退出"
E[30]="License should be 26 characters, please re-enter WARP+ License. Otherwise press Enter to continue. \(\${i} times remaining\):"
C[30]="License 应为26位字符,请重新输入 WARP+ License,没有可回车继续\(剩余\${i}次\):"
E[31]="The new \$KEY_LICENSE is the same as the one currently in use. Does not need to be replaced."
C[31]="新输入的 \$KEY_LICENSE 与现使用中的一样,不需要更换。"
E[32]="Step 1/3: Install dependencies..."
C[32]="进度 1/3: 安装系统依赖……"
E[33]="Step 2/3: WGCF is ready"
C[33]="进度 2/3: 已安装 WGCF"
E[34]="Failed to change port. Feedback: [https://github.com/fscarmen/warp/issues]"
C[34]="更换端口不成功,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[35]="Update WARP+ account..."
C[35]="升级 WARP+ 账户中……"
E[36]="The upgrade failed, License: \$LICENSE has been activated on more than 5 devices. The script will remain the same account or be switched to a free account."
C[36]="升级失败,License: \$LICENSE 已激活超过5台设备,将保持原账户或者转为免费账户。"
E[37]="Checking VPS infomation..."
C[37]="检查环境中……"
E[38]="Create shortcut [warp] successfully"
C[38]="创建快捷 warp 指令成功"
E[39]="Running WARP"
C[39]="运行 WARP"
E[40]="\$COMPANY vps needs to restart and run [warp n] to open WARP."
C[40]="\$COMPANY vps 需要重启后运行 warp n 才能打开 WARP,现执行重启"
E[41]="Congratulations! WARP\$TYPE is turned on. Spend time:\$(( end - start )) seconds.\\\n The script runs today: \$TODAY. Total:\$TOTAL"
C[41]="恭喜!WARP\$TYPE 已开启,总耗时:\$(( end - start ))秒, 脚本当天运行次数:\$TODAY,累计运行次数:\$TOTAL"
E[42]="The upgrade failed, License: \$LICENSE could not update to WARP+. The script will remain the same account or be switched to a free account."
C[42]="升级失败,License: \$LICENSE 不能升级为 WARP+,将保持原账户或者转为免费账户。"
E[43]="Run again with warp [option] [lisence], such as"
C[43]="再次运行用 warp [option] [lisence],如"
E[44]="WARP installation failed. Feedback: [https://github.com/fscarmen/warp/issues]"
C[44]="WARP 安装失败,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[45]="WARP interface, Linux Client and WirePorxy have been completely deleted!"
C[45]="WARP 网络接口、 Linux Client 和 WirePorxy 已彻底删除!"
E[46]="Not cleaned up, please reboot and try again."
C[46]="没有清除干净,请重启(reboot)后尝试再次删除"
E[47]="Upgrade kernel, turn on BBR, change Linux system by other authors [ylx2016],[https://github.com/ylx2016/Linux-NetSpeed]"
C[47]="BBR、DD脚本用的[ylx2016]的成熟作品,地址[https://github.com/ylx2016/Linux-NetSpeed],请熟知"
E[48]="Run script"
C[48]="安装脚本"
E[49]="Return to main menu"
C[49]="回退主目录"
E[50]="Choose:"
C[50]="请选择:"
E[51]="Please enter the correct number"
C[51]="请输入正确数字"
E[52]="Please input WARP+ ID:"
C[52]="请输入 WARP+ ID:"
E[53]="WARP+ ID should be 36 characters, please re-enter \(\${i} times remaining\):"
C[53]="WARP+ ID 应为36位字符,请重新输入 \(剩余\${i}次\):"
E[54]="Getting the WARP+ quota by the following 3 authors:\n • [ALIILAPRO],[https://github.com/ALIILAPRO/warp-plus-cloudflare]\n • [mixool],[https://github.com/mixool/across/tree/master/wireguard]\n • [SoftCreatR],[https://github.com/SoftCreatR/warp-up]\n • Open the 1.1.1.1 app\n • Click on the hamburger menu button on the top-right corner\n • Navigate to: Account > Key\n Important:Refresh WARP+ quota: 三 --> Advanced --> Connection options --> Reset keys\n It is best to run script with screen."
C[54]="刷 WARP+ 流量用可选择以下三位作者的成熟作品,请熟知:\n • [ALIILAPRO],地址[https://github.com/ALIILAPRO/warp-plus-cloudflare]\n • [mixool],地址[https://github.com/mixool/across/tree/master/wireguard]\n • [SoftCreatR],地址[https://github.com/SoftCreatR/warp-up]\n 下载地址:https://1.1.1.1/,访问和苹果外区 ID 自理\n 获取 WARP+ ID 填到下面。方法:App右上角菜单 三 --> 高级 --> 诊断 --> ID\n 重要:刷脚本后流量没有增加处理:右上角菜单 三 --> 高级 --> 连接选项 --> 重置加密密钥\n 最好配合 screen 在后台运行任务"
E[55]="1. Run [ALIILAPRO] script\n 2. Run [mixool] script\n 3. Run [SoftCreatR] script"
C[55]="1. 运行 [ALIILAPRO] 脚本\n 2. 运行 [mixool] 脚本\n 3. 运行 [SoftCreatR] 脚本"
E[56]="The current Netflix region is \$REGION. Confirm press [y] . If you want another regions, please enter the two-digit region abbreviation. \(such as hk,sg. Default is \$REGION\):"
C[56]="当前 Netflix 地区是:\$REGION,需要解锁当前地区请按 [y], 如需其他地址请输入两位地区简写 \(如 hk ,sg,默认:\$REGION\):"
E[57]="The target quota you want to get. The unit is GB, the default value is 10:"
C[57]="你希望获取的目标流量值,单位为 GB,输入数字即可,默认值为10:"
E[58]="Glibc 2.28 download failed. The script is aborted. Feedback: [https://github.com/fscarmen/warp/issues] "
C[58]="Glibc 2.28 下载失败,脚本中止,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[59]="Cannot find the account file: /etc/wireguard/wgcf-account.toml, you can reinstall with the WARP+ License"
C[59]="找不到账户文件:/etc/wireguard/wgcf-account.toml,可以卸载后重装,输入 WARP+ License"
E[60]="Cannot find the configuration file: /etc/wireguard/wgcf.conf, you can reinstall with the WARP+ License"
C[60]="找不到配置文件: /etc/wireguard/wgcf.conf,可以卸载后重装,输入 WARP+ License"
E[61]="Please Input WARP+ license:"
C[61]="请输入WARP+ License:"
E[62]="Successfully change to a WARP\$TYPE account"
C[62]="已变更为 WARP\$TYPE 账户"
E[63]="WARP+ quota"
C[63]="剩余流量"
E[64]="Successfully synchronized the latest version"
C[64]="成功!已同步最新脚本,版本号"
E[65]="Upgrade failed. Feedback:[https://github.com/fscarmen/warp/issues]"
C[65]="升级失败,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[66]="Add WARP IPv4 interface to \${NATIVE[n]} VPS \(bash menu.sh 4\)"
C[66]="为 \${NATIVE[n]} 添加 WARP IPv4 网络接口 \(bash menu.sh 4\)"
E[67]="Add WARP IPv6 interface to \${NATIVE[n]} VPS \(bash menu.sh 6\)"
C[67]="为 \${NATIVE[n]} 添加 WARP IPv6 网络接口 \(bash menu.sh 6\)"
E[68]="Add WARP dualstack interface to \${NATIVE[n]} VPS \(bash menu.sh d\)"
C[68]="为 \${NATIVE[n]} 添加 WARP 双栈网络接口 \(bash menu.sh d\)"
E[69]="Native dualstack"
C[69]="原生双栈"
E[70]="WARP dualstack"
C[70]="WARP 双栈"
E[71]="Turn on WARP (warp o)"
C[71]="打开 WARP (warp o)"
E[72]="Turn off, uninstall WARP interface, Linux Client and WireProxy (warp u)"
C[72]="永久关闭 WARP 网络接口,并删除 WARP、 Linux Client 和 WireProxy (warp u)"
E[73]="Upgrade kernel, turn on BBR, change Linux system (warp b)"
C[73]="升级内核、安装BBR、DD脚本 (warp b)"
E[74]="Getting WARP+ quota by scripts (warp p)"
C[74]="刷 WARP+ 流量 (warp p)"
E[75]="Sync the latest version (warp v)"
C[75]="同步最新版本 (warp v)"
E[76]="Exit"
C[76]="退出脚本"
E[77]="Turn off WARP (warp o)"
C[77]="暂时关闭 WARP (warp o)"
E[78]="Change the WARP account type (warp a)"
C[78]="变更 WARP 账户 (warp a)"
E[79]="Do you uninstall the following dependencies \(if any\)? Please note that this will potentially prevent other programs that are using the dependency from working properly.\\\n\\\n \$UNINSTALL_DEPENDENCIES_LIST"
C[79]="是否卸载以下依赖\(如有\)?请注意,这将有可能使其他正在使用该依赖的程序不能正常工作\\\n\\\n \$UNINSTALL_DEPENDENCIES_LIST"
E[80]="Professional one-click script for WARP to unblock streaming media (Supports multi-platform, multi-mode and TG push)"
C[80]="WARP 解锁 Netflix 等流媒体专业一键(支持多平台、多方式和 TG 通知)"
E[81]="Step 3/3: Searching for the best MTU value is ready."
C[81]="进度 3/3: 寻找 MTU 最优值已完成"
E[82]="Install CloudFlare Client and set mode to Proxy (bash menu.sh c)"
C[82]="安装 CloudFlare Client 并设置为 Proxy 模式 (bash menu.sh c)"
E[83]="Step 1/2: Installing WARP Client..."
C[83]="进度 1/2: 安装 Client……"
E[84]="Step 2/2: Setting Client Mode"
C[84]="进度 2/2: 设置 Client 模式"
E[85]="Client was installed.\n connect/disconnect by [warp r].\n uninstall by [warp u]"
C[85]="Linux Client 已安装\n 连接/断开: warp r\n 卸载: warp u"
E[86]="Client is working. Socks5 proxy listening on: \$(ss -nltp | grep -E 'warp|wireproxy' | awk '{print \$(NF-2)}')"
C[86]="Linux Client 正常运行中。 Socks5 代理监听:\$(ss -nltp | grep -E 'warp|wireproxy' | awk '{print \$(NF-2)}')"
E[87]="Fail to establish Socks5 proxy. Feedback: [https://github.com/fscarmen/warp/issues]"
C[87]="创建 Socks5 代理失败,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[88]="Connect the client (warp r)"
C[88]="连接 Client (warp r)"
E[89]="Disconnect the client (warp r)"
C[89]="断开 Client (warp r)"
E[90]="Client is connected"
C[90]="Client 已连接"
E[91]="Client is disconnected. It could be connect again by [warp r]"
C[91]="已断开 Client,再次连接可以用 warp r"
E[92]="(!!! Already installed, do not select.)"
C[92]="(!!! 已安装,请勿选择)"
E[93]="Client is not installed."
C[93]="Client 未安装"
E[94]="Congratulations! WARP\$AC Linux Client is working. Spend time:\$(( end - start )) seconds.\\\n The script runs on today: \$TODAY. Total:\$TOTAL"
C[94]="恭喜!WARP\$AC Linux Client 工作中, 总耗时:\$(( end - start ))秒, 脚本当天运行次数:\$TODAY,累计运行次数:\$TOTAL"
E[95]="Client works with non-WARP IPv4. The script is aborted. Feedback: [https://github.com/fscarmen/warp/issues]"
C[95]="Client 在非 WARP IPv4 下才能工作正常,脚本中止,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[96]="Client connecting failure. It may be a CloudFlare IPv4."
C[96]="Client 连接失败,可能是 CloudFlare IPv4."
E[97]="IPv\$PRIO priority"
C[97]="IPv\$PRIO 优先"
E[98]="Uninstall WirePorxy was complete."
C[98]="WirePorxy 卸载成功"
E[99]="WireProxy is connected"
C[99]="WireProxy 已连接"
E[100]="License should be 26 characters, please re-enter WARP+ License. Otherwise press Enter to continue. \(\${i} times remaining\): "
C[100]="License 应为26位字符,请重新输入 WARP+ License \(剩余\${i}次\): "
E[101]="Client support amd64 only. Curren architecture \$ARCHITECTURE. Official Support List: [https://pkg.cloudflareclient.com/packages/cloudflare-warp]. The script is aborted. Feedback: [https://github.com/fscarmen/warp/issues]"
C[101]="Client 只支持 amd64 架构,当前架构 \$ARCHITECTURE,官方支持列表: [https://pkg.cloudflareclient.com/packages/cloudflare-warp]。问题反馈:[https://github.com/fscarmen/warp/issues]"
E[102]="Please customize the WARP+ device name (Default is [WARP] if left blank):"
C[102]="请自定义 WARP+ 设备名 (如果不输入,默认为 [WARP]):"
E[103]="Port \$PORT is in use. Please input another Port\(\${i} times remaining\):"
C[103]="\$PORT 端口占用中,请使用另一端口\(剩余\${i}次\):"
E[104]="Please customize the Client port (1000-65535. Default to 40000 if it is blank):"
C[104]="请自定义 Client 端口号 (1000-65535,如果不输入,会默认40000):"
E[105]="Please choose the priority:\n 1. IPv4\n 2. IPv6\n 3. Use initial settings (default)"
C[105]="请选择优先级别:\n 1. IPv4\n 2. IPv6\n 3. 使用 VPS 初始设置 (默认)"
E[106]=""
C[106]=""
E[107]=""
C[107]=""
E[108]="\n 1. WARP Linux Client IP\n 2. WGCF WARP IP ( Only IPv6 can be brushed when WGCF and Client exist at the same time )\n"
C[108]="\n 1. WARP Linux Client IP\n 2. WGCF WARP IP ( WGCF 和 Client 并存时只能刷 IPv6)\n"
E[109]="Socks5 Proxy Client is working now. WARP IPv4 and dualstack interface could not be switch to. The script is aborted. Feedback: [https://github.com/fscarmen/warp/issues]"
C[109]="Socks5 代理正在运行中,不能转为 WARP IPv4 或者双栈网络接口,脚本中止,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[110]="Socks5 Proxy Client is working now. WARP IPv4 and dualstack interface could not be installed. The script is aborted. Feedback: [https://github.com/fscarmen/warp/issues]"
C[110]="Socks5 代理正在运行中,WARP IPv4 或者双栈网络接口不能安装,脚本中止,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[111]="Port must be 1000-65535. Please re-input\(\${i} times remaining\):"
C[111]="端口必须为 1000-65535,请重新输入\(剩余\${i}次\):"
E[112]="Client is not installed."
C[112]="Client 未安装"
E[113]="Client is installed. Mode is \$CLIENT_MODE. Disconnected"
C[113]="Client 已安装,模式为:\$CLIENT_MODE, 断开状态"
E[114]="WARP\$TYPE Interface is on"
C[114]="WARP\$TYPE 网络接口已开启"
E[115]="WARP Interface is on"
C[115]="WARP 网络接口已开启"
E[116]="WARP Interface is off"
C[116]="WARP 网络接口未开启"
E[117]="Uninstall WARP Interface was complete."
C[117]="WARP 网络接口卸载成功"
E[118]="Uninstall WARP Interface was fail."
C[118]="WARP 网络接口卸载失败"
E[119]="Uninstall Socks5 Proxy Client was complete."
C[119]="Socks5 Proxy Client 卸载成功"
E[120]="Uninstall Socks5 Proxy Client was fail."
C[120]="Socks5 Proxy Client 卸载失败"
E[121]="Changing Netflix IP is adapted from other authors [luoxue-bot],[https://github.com/luoxue-bot/warp_auto_change_ip]"
C[121]="更换支持 Netflix IP 改编自 [luoxue-bot] 的成熟作品,地址[https://github.com/luoxue-bot/warp_auto_change_ip],请熟知"
E[122]="Port change to \$PORT succeeded."
C[122]="端口成功更换至 \$PORT"
E[123]="Change the WARP IP to support Netflix (warp i)"
C[123]="更换支持 Netflix 的 IP (warp i)"
E[124]="1. Brush WARP IPv4 (default)\n 2. Brush WARP IPv6"
C[124]="1. 刷 WARP IPv4 (默认)\n 2. 刷 WARP IPv6"
E[125]="\$(date +'%F %T') Region: \$REGION Done. IPv\$NF: \$WAN \$COUNTRY \$ASNORG. Retest after 1 hour. Brush ip runing time:\$DAY days \$HOUR hours \$MIN minutes \$SEC seconds"
C[125]="\$(date +'%F %T') 区域 \$REGION 解锁成功,IPv\$NF: \$WAN \$COUNTRY \$ASNORG,1 小时后重新测试,刷 IP 运行时长: \$DAY 天 \$HOUR 时 \$MIN 分 \$SEC 秒"
E[126]="\$(date +'%F %T') Try \${i}. Failed. IPv\$NF: \$WAN \$COUNTRY \$ASNORG. Retry after \${j} seconds. Brush ip runing time:\$DAY days \$HOUR hours \$MIN minutes \$SEC seconds"
C[126]="\$(date +'%F %T') 尝试第\${i}次,解锁失败,IPv\$NF: \$WAN \$COUNTRY \$ASNORG,\${j}秒后重新测试,刷 IP 运行时长: \$DAY 天 \$HOUR 时 \$MIN 分 \$SEC 秒"
E[127]="Please input Teams file URL (To use the one provided by the script if left blank):"
C[127]="请输入 Teams 文件 URL (如果留空,则使用脚本提供的):"
E[128]=""
C[128]=""
E[129]="The current Teams account is unavailable, automatically switch back to the free account"
C[129]="当前 Teams 账户不可用,自动切换回免费账户"
E[130]="Please confirm\\\n Private key\\\t: \$PRIVATEKEY \$MATCH1\\\n Public key\\\t: \$PUBLICKEY \$MATCH2\\\n Address IPv4\\\t: \$ADDRESS4/32 \$MATCH3\\\n Address IPv6\\\t: \$ADDRESS6/128 \$MATCH4"
C[130]="请确认Teams 信息\\\n Private key\\\t: \$PRIVATEKEY \$MATCH1\\\n Public key\\\t: \$PUBLICKEY \$MATCH2\\\n Address IPv4\\\t: \$ADDRESS4/32 \$MATCH3\\\n Address IPv6\\\t: \$ADDRESS6/128 \$MATCH4"
E[131]="comfirm please enter [y] , and other keys to use free account:"
C[131]="确认请按 [y],其他按键则使用免费账户:"
E[132]="Is there a WARP+ or Teams account?\n 1. Use free account (default)\n 2. WARP+\n 3. Teams"
C[132]="如有 WARP+ 或 Teams 账户请选择\n 1. 使用免费账户 (默认)\n 2. WARP+\n 3. Teams"
E[133]="Device name: \$(grep -s 'Device name' /etc/wireguard/info.log | awk '{ print \$NF }')\\\n Quota: \$QUOTA"
C[133]="设备名: \$(grep -s 'Device name' /etc/wireguard/info.log | awk '{ print \$NF }')\\\n 剩余流量: \$QUOTA"
E[134]="Curren architecture \$(uname -m) is not supported. Feedback: [https://github.com/fscarmen/warp/issues]"
C[134]="当前架构 \$(uname -m) 暂不支持,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[135]="( match √ )"
C[135]="( 符合 √ )"
E[136]="( mismatch X )"
C[136]="( 不符合 X )"
E[137]="Cannot find the configuration file: /etc/wireguard/wgcf.conf. You should install WARP first"
C[137]="找不到配置文件 /etc/wireguard/wgcf.conf,请先安装 WARP"
E[138]="Install iptable + dnsmasq + ipset. Let WARP only take over the streaming media traffic (Not available for ipv6 only) (bash menu.sh e)"
C[138]="安装 iptable + dnsmasq + ipset,让 WARP IPv4 only 接管流媒体流量 (不适用于 IPv6 only VPS) (bash menu.sh e)"
E[139]="Through Iptable + dnsmasq + ipset, minimize the realization of media unblocking such as Netflix, WARP IPv4 only takes over the streaming media traffic,adapted from the mature works of [Anemone],[https://github.com/acacia233/Project-WARP-Unlock]"
C[139]="通过 Iptable + dnsmasq + ipset,最小化实现 Netflix 等媒体解锁,WARP IPv4 只接管流媒体流量,改编自 [Anemone] 的成熟作品,地址[https://github.com/acacia233/Project-WARP-Unlock],请熟知"
E[140]="Socks5 Proxy Client on IPv4 VPS is working now. WARP IPv6 interface could not be installed. Feedback: [https://github.com/fscarmen/warp/issues]"
C[140]="IPv4 only VPS,并且 Socks5 代理正在运行中,不能安装 WARP IPv6 网络接口,问题反馈:[https://github.com/fscarmen/warp/issues]"
E[141]="Switch \${WARP_BEFORE[m]} to \${WARP_AFTER1[m]} \${SHORTCUT1[m]}"
C[141]="\${WARP_BEFORE[m]} 转为 \${WARP_AFTER1[m]} \${SHORTCUT1[m]}"
E[142]="Switch \${WARP_BEFORE[m]} to \${WARP_AFTER2[m]} \${SHORTCUT2[m]}"
C[142]="\${WARP_BEFORE[m]} 转为 \${WARP_AFTER2[m]} \${SHORTCUT2[m]}"
E[143]="Change Client or WireProxy port"
C[143]="更改 Client 或 WireProxy 端口"
E[144]="Install WARP IPv6 interface"
C[144]="安装 WARP IPv6 网络接口"
E[145]=""
C[145]=""
E[146]="Cannot switch to the same form as the current one."
C[146]="不能切换为当前一样的形态"
E[147]="Not available for IPv6 only VPS"
C[147]="IPv6 only VPS 不能使用此方案"
E[148]="Install wireproxy. Wireguard client that exposes itself as a socks5 proxy or tunnels (bash menu.sh w)"
C[148]="安装 wireproxy,让 WARP 在本地创建一个 socks5 代理 (bash menu.sh w)"
E[149]="Congratulations! WirePorxy is working. Spend time:\$(( end - start )) seconds.\\\n The script runs on today: \$TODAY. Total:\$TOTAL"
C[149]="恭喜!WirePorxy 工作中, 总耗时:\$(( end - start ))秒, 脚本当天运行次数:\$TODAY,累计运行次数:\$TOTAL"
E[150]="WGCF WARP, WARP Linux Client, WireProxy hasn't been installed yet. The script is aborted.\n"
E[151]="1. WARP Linux Client account\n 2. WireProxy account"
C[151]="1. WARP Linux Client 账户\n 2. WireProxy 账户"
E[152]="1. WGCF WARP account\n 2. WireProxy account"
C[152]="1. WGCF WARP 账户\n 2. WireProxy 账户"
E[153]="1. WGCF WARP account\n 2. WARP Linux Client account"
C[153]="1. WGCF WARP 账户\n 2. WARP Linux Client 账户"
E[154]="1. WGCF WARP account\n 2. WARP Linux Client account\n 3. WireProxy account"
C[154]="1. WGCF WARP 账户\n 2. WARP Linux Client 账户\n 3. WireProxy 账户"
E[155]="WGCF WARP has not been installed yet."
C[155]="WGCF WARP 还未安装"
E[156]="(!!! AMD64 only, do not select.)"
C[156]="(!!! 只支持 AMD64,请勿选择)"
E[157]="WireProxy has not been installed yet."
C[157]="WireProxy 还未安装"
E[158]="WireProxy is disconnected. It could be connect again by [warp y]"
C[158]="已断开 WirePorxy,再次连接可以用 warp y"
E[159]="WireProxy is on"
C[159]="WireProxy 已开启"
E[160]="WireProxy is not installed."
C[160]="WireProxy 未安装"
E[161]="WireProxy is installed and disconnected"
C[161]="WireProxy 已安装,状态为断开连接"
E[162]=""
C[162]=""
E[163]="Connect the WirePorxy (warp y)"
C[163]="连接 WirePorxy (warp y)"
E[164]="Disconnect the WirePorxy (warp y)"
C[164]="断开 WirePorxy (warp y)"
E[165]="WireProxy Solution. A wireguard client that exposes itself as a socks5 proxy or tunnels. Adapted from the mature works of [octeep],[https://github.com/octeep/wireproxy]"
C[165]="WireProxy,让 WARP 在本地建议一个 socks5 代理。改编自 [octeep] 的成熟作品,地址[https://github.com/octeep/wireproxy],请熟知"
E[166]="WireProxy was installed.\n connect/disconnect by [warp y]\n uninstall by [warp u]"
C[166]="WireProxy 已安装\n 连接/断开: warp y\n 卸载: warp u"
E[167]="WARP iptable was installed.\n connect/disconnect by [warp o]\n uninstall by [warp u]"
C[167]="WARP iptable 已安装\n 连接/断开: warp o\n 卸载: warp u"
E[168]="Install CloudFlare Client and set mode to WARP (bash menu.sh l)"
C[168]="安装 CloudFlare Client 并设置为 WARP 模式 (bash menu.sh l)"
E[169]="WARP\$AC IPv4: \$WAN4 \$WARPSTATUS4 \$COUNTRY4 \$ASNORG4"
C[169]="WARP\$AC IPv4: \$WAN4 \$WARPSTATUS4 \$COUNTRY4 \$ASNORG4"
E[170]="Confirm all uninstallation please press [y], other keys do not uninstall by default:"
C[170]="确认全部卸载请按 [y],其他键默认不卸载:"
E[171]="Uninstall dependencies were complete."
C[171]="依赖卸载成功"
E[172]="No suitable solution was found for modifying the wgcf configuration file wgcf.conf and the script aborted. When you see this message, please send feedback on the bug to:[https://github.com/fscarmen/warp/issues]"
C[172]="没有找到适合的方案用于修改 wgcf 配置文件 wgcf.conf,脚本中止。当你看到此信息,请把该 bug 反馈至:[https://github.com/fscarmen/warp/issues]"
E[173]="Current account type is: WARP \$ACCOUNT_TYPE\\\t \$PLUS_QUOTA\\\n \$CHANGE_TYPE"
C[173]="当前账户类型是: WARP \$ACCOUNT_TYPE\\\t \$PLUS_QUOTA\\\n \$CHANGE_TYPE"
E[174]="1. Continue using the free account without changing.\n 2. Change to WARP+ account.\n 3. Change to Teams account. (You need upload the Teams file to a private storage space before. For example: gist.github.com)"
C[174]="1. 继续使用 free 账户,不变更\n 2. 变更为 WARP+ 账户\n 3. 变更为 Teams 账户 (你须事前把 Teams 文件上传到私密存储空间,比如:gist.github.com)"
E[175]="1. Change to free account.\n 2. Change to WARP+ account.\n 3. Change to another WARP Teams account. (You need upload the Teams file to a private storage space before. For example: gist.github.com)"
C[175]="1. 变更为 free 账户\n 2. 变更为 WARP+ 账户\n 3. 更换为另一个 Teams 账户 (你须事前把 Teams 文件上传到私密存储空间,比如:gist.github.com)"
E[176]="1. Change to free account.\n 2. Change to another WARP+ account.\n 3. Change to Teams account. (You need upload the Teams file to a private storage space before. For example: gist.github.com)"
C[176]="1. 变更为 free 账户\n 2. 变更为另一个 WARP+ 账户\n 3. 变更为 Teams 账户 (你须事前把 Teams 文件上传到私密存储空间,比如:gist.github.com)"
E[177]="1. Continue using the free account without changing.\n 2. Change to WARP+ account."
C[177]="1. 继续使用 free 账户,不变更\n 2. 变更为 WARP+ 账户"
E[178]="1. Change to free account.\n 2. Change to another WARP+ account."
C[178]="1. 变更为 free 账户\n 2. 变更为另一个 WARP+ 账户"
# 自定义字体彩色,read 函数,友道翻译函数
warning() { echo -e "\033[31m\033[01m$*\033[0m"; }
error() { echo -e "\033[31m\033[01m$*\033[0m" && exit 1; }
info() { echo -e "\033[32m\033[01m$*\033[0m"; }
hint() { echo -e "\033[33m\033[01m$*\033[0m"; }
reading() { read -rp "$(info "$1")" "$2"; }
text() { eval echo "\${${L}[$*]}"; }
text_eval() { eval echo "\$(eval echo "\${${L}[$*]}")"; }
translate() { [ -n "$1" ] && curl -ksm8 "http://fanyi.youdao.com/translate?&doctype=json&type=AUTO&i=$1" | cut -d \" -f18 2>/dev/null; }
# 脚本当天及累计运行次数统计
statistics_of_run-times() {
COUNT=$(
curl -4 -ksm1 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Ffscarmen%2Fwarp%2Fmenu.sh&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=&edge_flat=true" 2>&1 ||
curl -6 -ksm1 "https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Ffscarmen%2Fwarp%2Fmenu.sh&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=&edge_flat=true" 2>&1) &&
TODAY=$(expr "$COUNT" : '.*\s\([0-9]\{1,\}\)\s/.*') && TOTAL=$(expr "$COUNT" : '.*/\s\([0-9]\{1,\}\)\s.*')
}
# 选择语言,先判断 /etc/wireguard/language 里的语言选择,没有的话再让用户选择,默认英语
select_language() {
case $(cat /etc/wireguard/language 2>&1) in
E ) L=E ;;
C ) L=C ;;
* ) L=E && [[ -z "$OPTION" || "$OPTION" = [aclehdpbviw46s] ]] && hint " $(text 0) " && reading " $(text 50) " LANGUAGE
[ "$LANGUAGE" = 2 ] && L=C ;;
esac
}
# 必须以root运行脚本
check_root_virt() {
[ "$(id -u)" != 0 ] && error " $(text 2) "
# 判断虚拟化,选择 Wireguard内核模块 还是 Wireguard-Go
VIRT=$(systemd-detect-virt 2>/dev/null | tr 'A-Z' 'a-z')
[ -n "$VIRT" ] || VIRT=$(hostnamectl 2>/dev/null | tr 'A-Z' 'a-z' | grep virtualization | sed "s/.*://g")
[[ "$VIRT" =~ openvz|lxc || -z "$VIRT" ]] && LXC=1
}
# 多方式判断操作系统,试到有值为止。只支持 Debian 10/11、Ubuntu 18.04/20.04 或 CentOS 7/8 ,如非上述操作系统,退出脚本
# 感谢猫大的技术指导优化重复的命令。https://github.com/Oreomeow
check_operating_system() {
CMD=( "$(grep -i pretty_name /etc/os-release 2>/dev/null | cut -d \" -f2)"
"$(hostnamectl 2>/dev/null | grep -i system | cut -d : -f2)"
"$(lsb_release -sd 2>/dev/null)"
"$(grep -i description /etc/lsb-release 2>/dev/null | cut -d \" -f2)"
"$(grep . /etc/redhat-release 2>/dev/null)"
"$(grep . /etc/issue 2>/dev/null | cut -d \\ -f1 | sed '/^[ ]*$/d')"
)
for i in "${CMD[@]}"; do
SYS="$i" && [ -n "$SYS" ] && break
done
# 自定义 Alpine 系统若干函数
alpine_wgcf_restart() { wg-quick down wgcf >/dev/null 2>&1; wg-quick up wgcf >/dev/null 2>&1; }
alpine_wgcf_enable() { echo -e "/usr/bin/tun.sh\nwg-quick up wgcf" > /etc/local.d/wgcf.start; chmod +x /etc/local.d/wgcf.start; rc-update add local; }
REGEX=("debian" "ubuntu" "centos|red hat|kernel|oracle linux|alma|rocky" "amazon linux" "alpine" "arch linux")
RELEASE=("Debian" "Ubuntu" "CentOS" "CentOS" "Alpine" "Arch")
EXCLUDE=("bookworm")
COMPANY=("" "" "" "amazon" "" "")
MAJOR=("9" "16" "7" "7" "3" "")
PACKAGE_UPDATE=("apt -y update" "apt -y update" "yum -y update" "yum -y update" "apk update -f" "pacman -Sy")
PACKAGE_INSTALL=("apt -y install" "apt -y install" "yum -y install" "yum -y install" "apk add -f" "pacman -S --noconfirm")
PACKAGE_UNINSTALL=("apt -y autoremove" "apt -y autoremove" "yum -y autoremove" "yum -y autoremove" "apk del -f" "pacman -Rcnsu --noconfirm")
SYSTEMCTL_START=("systemctl start wg-quick@wgcf" "systemctl start wg-quick@wgcf" "systemctl start wg-quick@wgcf" "systemctl start wg-quick@wgcf" "wg-quick up wgcf" "systemctl start wg-quick@wgcf")
SYSTEMCTL_RESTART=("systemctl restart wg-quick@wgcf" "systemctl restart wg-quick@wgcf" "systemctl restart wg-quick@wgcf" "systemctl restart wg-quick@wgcf" "alpine_wgcf_restart" "systemctl restart wg-quick@wgcf")
SYSTEMCTL_ENABLE=("systemctl enable --now wg-quick@wgcf" "systemctl enable --now wg-quick@wgcf" "systemctl enable --now wg-quick@wgcf" "systemctl enable --now wg-quick@wgcf" "alpine_wgcf_enable" "systemctl enable --now wg-quick@wgcf")
for ((int=0; int<${#REGEX[@]}; int++)); do
[[ $(tr 'A-Z' 'a-z' <<< "$SYS") =~ ${REGEX[int]} ]] && SYSTEM="${RELEASE[int]}" && COMPANY="${COMPANY[int]}" && [ -n "$SYSTEM" ] && break
done
[ -z "$SYSTEM" ] && error " $(text 5) "
# 先排除 EXCLUDE 里包括的特定系统,其他系统需要作大发行版本的比较
for ex in "${EXCLUDE[@]}"; do [[ ! $(tr 'A-Z' 'a-z' <<< "$SYS") =~ $ex ]]; done &&
[[ "$(echo "$SYS" | sed "s/[^0-9.]//g" | cut -d. -f1)" -lt "${MAJOR[int]}" ]] && error " $(text_eval 26) "
}
# 安装系统依赖及定义 ping 指令
check_dependencies() {
# 对于 alpine 系统,升级库并重新安装依赖
if [ "$SYSTEM" = Alpine ]; then
[ ! -e /etc/wireguard/menu.sh ] && ( ${PACKAGE_UPDATE[int]}; ${PACKAGE_INSTALL[int]} curl wget grep bash )
else
DEPS_CHECK=("ping" "wget" "curl" "systemctl" "ip")
DEPS_INSTALL=(" iputils-ping" " wget" " curl" " systemctl" " iproute2")
for ((g=0; g<${#DEPS_CHECK[@]}; g++)); do [ ! $(type -p ${DEPS_CHECK[g]}) ] && DEPS+=${DEPS_INSTALL[g]}; done
if [ -n "$DEPS" ]; then
info "\n $(text 7) $DEPS \n"
${PACKAGE_UPDATE[int]} >/dev/null 2>&1
${PACKAGE_INSTALL[int]} $DEPS >/dev/null 2>&1
else
info "\n $(text 8) \n"
fi
fi
PING6='ping -6' && [ $(type -p ping6) ] && PING6='ping6'
}
# 检测 IPv4 IPv6 信息,WARP Ineterface 开启,普通还是 Plus账户 和 IP 信息
ip4_info() {
unset IP4 COUNTRY4 ASNORG4 TRACE4 PLUS4 WARPSTATUS4
IP4=$(curl -ks4m8 -A Mozilla $IP_API $INTERFACE)
WAN4=$(expr "$IP4" : '.*ip\":[ ]*\"\([^"]*\).*')
COUNTRY4=$(expr "$IP4" : '.*country\":[ ]*\"\([^"]*\).*')
ASNORG4=$(expr "$IP4" : '.*'$ISP'\":[ ]*\"\([^"]*\).*')
TRACE4=$(curl -ks4m8 https://www.cloudflare.com/cdn-cgi/trace | grep warp | sed "s/warp=//g")
if [ "$TRACE4" = plus ]; then
[[ -e /etc/wireguard/info.log || -e /etc/wireguard/info-temp.log ]] && PLUS4=' Teams' && grep -sq 'Device name' /etc/wireguard/info.log && PLUS4='+'
fi
[[ "$TRACE4" =~ on|plus ]] && WARPSTATUS4="( WARP$PLUS4 IPv4 )"
}
ip6_info() {
unset IP6 COUNTRY6 ASNORG6 TRACE6 PLUS6 WARPSTATUS6
IP6=$(curl -ks6m8 -A Mozilla $IP_API)
WAN6=$(expr "$IP6" : '.*ip\":[ ]*\"\([^"]*\).*')
COUNTRY6=$(expr "$IP6" : '.*country\":[ ]*\"\([^"]*\).*')
ASNORG6=$(expr "$IP6" : '.*'$ISP'\":[ ]*\"\([^"]*\).*')
TRACE6=$(curl -ks6m8 https://www.cloudflare.com/cdn-cgi/trace | grep warp | sed "s/warp=//g")
if [ "$TRACE6" = plus ]; then
[[ -e /etc/wireguard/info.log || -e /etc/wireguard/info-temp.log ]] && PLUS6=' Teams' && grep -sq 'Device name' /etc/wireguard/info.log && PLUS6='+'
fi
[[ "$TRACE6" =~ on|plus ]] && WARPSTATUS6="( WARP$PLUS6 IPv6 )"
}
# 检测 Client 是否开启,free 还是 Plus 账户 和 IP 信息
proxy_info() {
unset PROXYSOCKS5 PROXYPORT PROXYJASON PROXYIP PROXYCOUNTR PROXYASNORG ACCOUNT QUOTA AC PROXYSOCKS52 PROXYPORT2 PROXYJASON2 PROXYIP2 PROXYCOUNTR2 PROXYASNORG2 ACCOUNT2 AC2 TRACE42
if [ $(type -p warp-cli) ]; then
PROXYSOCKS5=$(ss -nltp | grep 'warp' | awk '{print $(NF-2)}')
PROXYPORT=$(echo "$PROXYSOCKS5" | cut -d: -f2)
PROXYJASON=$(curl -sx socks5h://localhost:$PROXYPORT -A Mozilla $IP_API)
PROXYIP=$(expr "$PROXYJASON" : '.*ip\":[ ]*\"\([^"]*\).*')
PROXYCOUNTRY=$(expr "$PROXYJASON" : '.*country\":[ ]*\"\([^"]*\).*')
[ "$L" = C ] && PROXYCOUNTRY=$(translate "$PROXYCOUNTRY")
PROXYASNORG=$(expr "$PROXYJASON" : '.*'$ISP'\":[ ]*\"\([^"]*\).*')
ACCOUNT=$(warp-cli --accept-tos account 2>/dev/null)
[[ "$ACCOUNT" =~ Limited ]] && AC='+' && check_quota
fi
if [ $(type -p wireproxy) ]; then
PROXYSOCKS52=$(ss -nltp | grep 'wireproxy' | awk '{print $(NF-2)}')
PROXYPORT2=$(echo "$PROXYSOCKS52" | cut -d: -f2)
PROXYJASON2=$(curl -sx socks5h://localhost:$PROXYPORT2 -A Mozilla $IP_API)
PROXYIP2=$(expr "$PROXYJASON2" : '.*ip\":[ ]*\"\([^"]*\).*')
PROXYCOUNTRY2=$(expr "$PROXYJASON2" : '.*country\":[ ]*\"\([^"]*\).*')
[ "$L" = C ] && PROXYCOUNTRY2=$(translate "$PROXYCOUNTRY2")
PROXYASNORG2=$(expr "$PROXYJASON2" : '.*'$ISP'\":[ ]*\"\([^"]*\).*')
TRACE42=$(eval echo "\$(curl -sx socks5h://localhost:$(ss -nltp | grep wireproxy | awk '{print $(NF-2)}' | cut -d: -f2) https://www.cloudflare.com/cdn-cgi/trace)")
AC2=' free' && [[ "$TRACE42" =~ plus ]] && [ -e /etc/wireguard/info.log ] && AC2=' Teams' && grep -sq 'Device name' /etc/wireguard/info.log && AC2='+' && check_quota
fi
}
# 帮助说明
help() { hint " $(text 6) "; }
# 刷 WARP+ 流量
input() {
reading " $(text 52) " ID
i=5
until [[ "$ID" =~ ^[A-F0-9a-f]{8}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{4}-[A-F0-9a-f]{12}$ ]]; do
(( i-- )) || true
[ "$i" = 0 ] && error " $(text 29) " || reading " $(text_eval 53) " ID
done
}
plus() {
echo -e "\n==============================================================\n"
info " $(text 54) "
echo -e "\n==============================================================\n"
hint " $(text 55) "
[ "$OPTION" != p ] && hint " 0. $(text 49) \n" || hint " 0. $(text 76) \n"
reading " $(text 50) " CHOOSEPLUS
case "$CHOOSEPLUS" in
1 ) input
[ $(type -p git) ] || ${PACKAGE_INSTALL[int]} git 2>/dev/null
[ $(type -p python3) ] || ${PACKAGE_INSTALL[int]} python3 2>/dev/null
[ -d ~/warp-plus-cloudflare ] || git clone https://github.com/aliilapro/warp-plus-cloudflare.git
echo "$ID" | python3 ~/warp-plus-cloudflare/wp-plus.py ;;
2 ) input
reading " $(text 57) " MISSION
MISSION=${MISSION//[^0-9]/}
bash <(wget --no-check-certificate -qO- -T8 https://raw.githubusercontent.com/fscarmen/tools/main/warp_plus.sh) $MISSION $ID ;;
3 ) input
reading " $(text 57) " MISSION
MISSION=${MISSION//[^0-9]/}
bash <(wget --no-check-certificate -qO- -T8 https://raw.githubusercontent.com/SoftCreatR/warp-up/main/warp-up.sh) --disclaimer --id $ID --iterations $MISSION ;;
0 ) [ "$OPTION" != p ] && menu || exit ;;
* ) warning " $(text 51) [0-3] "; sleep 1; plus ;;
esac
}
# IPv4 / IPv6 优先设置
stack_priority() {
[ "$OPTION" = s ] && case "$PRIORITY_SWITCH" in
4 ) PRIORITY=1 ;;
6 ) PRIORITY=2 ;;
d ) : ;;
* ) hint "\n $(text 105) \n" && reading " $(text 50) " PRIORITY ;;
esac
[ -e /etc/gai.conf ] && sed -i '/^precedence \:\:ffff\:0\:0/d;/^label 2002\:\:\/16/d' /etc/gai.conf
case "$PRIORITY" in
1 ) echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf ;;
2 ) echo "label 2002::/16 2" >> /etc/gai.conf ;;
esac
}
# IPv4 / IPv6 优先结果
result_priority() {
PRIO=(0 0)
if [ -e /etc/gai.conf ]; then
grep -qsE "^precedence[ ]+::ffff:0:0/96[ ]+100" /etc/gai.conf && PRIO[0]=1
grep -qsE "^label[ ]+2002::/16[ ]+2" /etc/gai.conf && PRIO[1]=1
fi
case "${PRIO[*]}" in
'1 0' ) PRIO=4 ;;
'0 1' ) PRIO=6 ;;
* ) [[ "$(curl -ksm8 -A Mozilla $IP_API | grep '"ip"' | sed 's/.*ip\":[ ]*\"\([^"]*\).*/\1/g')" =~ ^([0-9]{1,3}\.){3} ]] && PRIO=4 || PRIO=6 ;;
esac
PRIORITY_NOW=$(text_eval 97)
# 如是快捷方式切换优先级别的话,显示结果
[ "$OPTION" = s ] && hint "\n $PRIORITY_NOW \n"
}
# 更换 Netflix IP 时确认期望区域
input_region() {
[ -n "$NF" ] && REGION=$(tr 'a-z' 'A-Z' <<< "$(curl --user-agent "${UA_Browser}" -$NF -fs --max-time 10 --write-out %{redirect_url} --output /dev/null "https://www.netflix.com/title/$REGION_TITLE" | sed 's/.*com\/\([^-/]\{1,\}\).*/\1/g')")
[ -n "$PROXYPORT" ] && REGION=$(tr 'a-z' 'A-Z' <<< "$(curl --user-agent "${UA_Browser}" -sx socks5h://localhost:$PROXYPORT -fs --max-time 10 --write-out %{redirect_url} --output /dev/null "https://www.netflix.com/title/$REGION_TITLE" | sed 's/.*com\/\([^-/]\{1,\}\).*/\1/g')")
[ -n "$INTERFACE" ] && REGION=$(tr 'a-z' 'A-Z' <<< "$(curl --user-agent "${UA_Browser}" $INTERFACE -fs --max-time 10 --write-out %{redirect_url} --output /dev/null "https://www.netflix.com/title/$REGION_TITLE" | sed 's/.*com\/\([^-/]\{1,\}\).*/\1/g')")
REGION=${REGION:-'US'}
reading " $(text_eval 56) " EXPECT
until [[ -z "$EXPECT" || "$EXPECT" = [Yy] || "$EXPECT" =~ ^[A-Za-z]{2}$ ]]; do
reading " $(text_eval 56) " EXPECT
done
[[ -z "$EXPECT" || "$EXPECT" = [Yy] ]] && EXPECT="$REGION"
}
# 更换支持 Netflix WARP IP 改编自 [luoxue-bot] 的成熟作品,地址[https://github.com/luoxue-bot/warp_auto_change_ip]
change_ip() {
change_wgcf() {
wgcf_restart() { warning " $(text_eval 126) " && ${SYSTEMCTL_RESTART[int]}; ss -nltp | grep dnsmasq >/dev/null 2>&1 && systemctl restart dnsmasq >/dev/null 2>&1; sleep $j; }
unset T4 T6
grep -q "^#.*0\.\0\/0" /etc/wireguard/wgcf.conf && T4=0 || T4=1
grep -q "^#.*\:\:\/0" /etc/wireguard/wgcf.conf && T6=0 || T6=1
case "$T4$T6" in
01 ) NF='6' ;;
10 ) NF='4' ;;
11 ) hint "\n $(text 124) \n" && reading " $(text 50) " NETFLIX
NF='4' && [ "$NETFLIX" = 2 ] && NF='6' ;;
esac
[ -z "$EXPECT" ] && input_region
i=0; j=5
while true; do
(( i++ )) || true
ip_now=$(date +%s); RUNTIME=$((ip_now - ip_start)); DAY=$(( RUNTIME / 86400 )); HOUR=$(( (RUNTIME % 86400 ) / 3600 )); MIN=$(( (RUNTIME % 86400 % 3600) / 60 )); SEC=$(( RUNTIME % 86400 % 3600 % 60 ))
ip${NF}_info
WAN=$(eval echo \$WAN$NF) && ASNORG=$(eval echo \$ASNORG$NF)
[ "$L" = C ] && COUNTRY=$(translate "$(eval echo \$COUNTRY$NF)") || COUNTRY=$(eval echo \$COUNTRY$NF)
RESULT=$(curl --user-agent "${UA_Browser}" -$NF -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/$RESULT_TITLE" 2>&1)
if [ "$RESULT" = 200 ]; then
REGION=$(tr 'a-z' 'A-Z' <<< $(curl --user-agent "${UA_Browser}" -"$NF" -fs --max-time 10 --write-out %{redirect_url} --output /dev/null "https://www.netflix.com/title/$REGION_TITLE" | sed 's/.*com\/\([^-/]\{1,\}\).*/\1/g'))
REGION=${REGION:-'US'}
echo "$REGION" | grep -qi "$EXPECT" && info " $(text_eval 125) " && i=0 && sleep 1h || wgcf_restart
else
wgcf_restart
fi
done
}
change_client() {
client_restart() {
[[ $(warp-cli --accept-tos settings) =~ WarpProxy ]] && CLIENT_PROXY=1
warning " $(text_eval 126) " && warp-cli --accept-tos delete >/dev/null 2>&1
[ "$CLIENT_PROXY" != 1 ] && rule_del >/dev/null 2>&1
warp-cli --accept-tos register >/dev/null 2>&1 &&
[ -e /etc/wireguard/license ] && warp-cli --accept-tos set-license $(cat /etc/wireguard/license) >/dev/null 2>&1
sleep $j
[ "$CLIENT_PROXY" != 1 ] && rule_add >/dev/null 2>&1
}
if [[ $(warp-cli --accept-tos settings) =~ WarpProxy ]]; then
PROXYPORT="$(ss -nltp | grep 'warp' | awk '{print $(NF-2)}' | cut -d: -f2)"
[ -z "$EXPECT" ] && input_region
i=0; j=10
while true; do
(( i++ )) || true
ip_now=$(date +%s); RUNTIME=$((ip_now - ip_start)); DAY=$(( RUNTIME / 86400 )); HOUR=$(( (RUNTIME % 86400 ) / 3600 )); MIN=$(( (RUNTIME % 86400 % 3600) / 60 )); SEC=$(( RUNTIME %86400 % 3600 % 60 ))
proxy_info
WAN=$PROXYIP && ASNORG=$PROXYASNORG && NF=4 && COUNTRY=$PROXYCOUNTRY
RESULT=$(curl --user-agent "${UA_Browser}" -sx socks5h://localhost:$PROXYPORT -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/$RESULT_TITLE" 2>&1)
if [ "$RESULT" = 200 ]; then
REGION=$(tr 'a-z' 'A-Z' <<< $(curl --user-agent "${UA_Browser}" -sx socks5h://localhost:$PROXYPORT -fs --max-time 10 --write-out %{redirect_url} --output /dev/null "https://www.netflix.com/title/$REGION_TITLE" | sed 's/.*com\/\([^-/]\{1,\}\).*/\1/g'))
REGION=${REGION:-'US'}
echo "$REGION" | grep -qi "$EXPECT" && info " $(text_eval 125) " && i=0 && sleep 1h || client_restart
else
client_restart
fi
done
else
INTERFACE='--interface CloudflareWARP'
[ -z "$EXPECT" ] && input_region
i=0; j=10
while true; do
(( i++ )) || true
ip_now=$(date +%s); RUNTIME=$((ip_now - ip_start)); DAY=$(( RUNTIME / 86400 )); HOUR=$(( (RUNTIME % 86400 ) / 3600 )); MIN=$(( (RUNTIME % 86400 % 3600) / 60 )); SEC=$(( RUNTIME % 86400 % 3600 % 60 ))
ip4_info
WAN=$WAN4 && ASNORG=$ASNORG4 && NF=4
[ "$L" = C ] && COUNTRY=$(translate "$COUNTRY4") || COUNTRY=$COUNTRY4
RESULT=$(curl --user-agent "${UA_Browser}" $INTERFACE -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/$RESULT_TITLE" 2>&1)
if [ "$RESULT" = 200 ]; then
REGION=$(tr 'a-z' 'A-Z' <<< $(curl --user-agent "${UA_Browser}" $INTERFACE -fs --max-time 10 --write-out %{redirect_url} --output /dev/null "https://www.netflix.com/title/$REGION_TITLE" | sed 's/.*com\/\([^-/]\{1,\}\).*/\1/g'))
REGION=${REGION:-'US'}
echo "$REGION" | grep -qi "$EXPECT" && info " $(text_eval 125) " && i=0 && sleep 1h || client_restart
else
client_restart
fi
done
fi
}
change_wireproxy() {
wireproxy_restart() { warning " $(text_eval 126) " && systemctl restart wireproxy; sleep $j; }
PROXYPORT="$(ss -nltp | grep 'wireproxy' | awk '{print $(NF-2)}' | cut -d: -f2)"
[ -z "$EXPECT" ] && input_region
i=0; j=5
while true; do
(( i++ )) || true
ip_now=$(date +%s); RUNTIME=$((ip_now - ip_start)); DAY=$(( RUNTIME / 86400 )); HOUR=$(( (RUNTIME % 86400 ) / 3600 )); MIN=$(( (RUNTIME % 86400 % 3600) / 60 )); SEC=$(( RUNTIME % 86400 % 3600 % 60 ))
proxy_info
WAN=$PROXYIP2 && ASNORG=$PROXYASNORG2 && COUNTRY=$PROXYCOUNTRY2
RESULT=$(curl --user-agent "${UA_Browser}" -sx socks5h://localhost:$PROXYPORT -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/$RESULT_TITLE" 2>&1)
if [ "$RESULT" = 200 ]; then
REGION=$(tr 'a-z' 'A-Z' <<< $(curl --user-agent "${UA_Browser}" -sx socks5h://localhost:$PROXYPORT -fs --max-time 10 --write-out %{redirect_url} --output /dev/null "https://www.netflix.com/title/$REGION_TITLE" | sed 's/.*com\/\([^-/]\{1,\}\).*/\1/g'))
REGION=${REGION:-'US'}
echo "$REGION" | grep -qi "$EXPECT" && info " $(text_eval 125) " && i=0 && sleep 1h || wireproxy_restart
else
wireproxy_restart
fi
done
}
# 设置时区,让时间戳时间准确,显示脚本运行时长,中文为 GMT+8,英文为 UTC; 设置 UA
ip_start=$(date +%s)
[ "$SYSTEM" != Alpine ] && ( [ "$L" = C ] && timedatectl set-timezone Asia/Shanghai || timedatectl set-timezone UTC )
UA_Browser="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36"
# 根据 lmc999 脚本检测 Netflix Title,如获取不到,使用兜底默认值
LMC999=$(curl -sSLm4 https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/check.sh)
RESULT_TITLE=$(echo "$LMC999" | grep "result.*netflix.com/title/" | sed "s/.*title\/\([^\"]*\).*/\1/")
REGION_TITLE=$(echo "$LMC999" | grep "region.*netflix.com/title/" | sed "s/.*title\/\([^\"]*\).*/\1/")
RESULT_TITLE=${RESULT_TITLE:-'80062035'}; REGION_TITLE=${REGION_TITLE:-'80018499'}
# 根据 WARP interface 、 Client 和 WirePorxy 的安装情况判断刷 IP 的方式
INSTALL_CHECK=("wg-quick" "warp-cli" "wireproxy")
CASE_RESAULT=("0 0 0" "0 0 1" "0 1 0" "0 1 1" "1 0 0" "1 0 1" "1 1 0" "1 1 1")
SHOW_CHOOSE=("$(text 150)" "" "" "$(text 151)" "" "$(text 152)" "$(text 153)" "$(text 154)")
CHANGE_IP1=("" "change_wireproxy" "change_client" "change_client" "change_wgcf" "change_wgcf" "change_wgcf" "change_wgcf")
CHANGE_IP2=("" "" "" "change_wireproxy" "" "change_wireproxy" "change_client" "change_client")
CHANGE_IP3=("" "" "" "" "" "" "" "change_wireproxy")
for ((a=0; a<${#INSTALL_CHECK[@]}; a++)); do
[ $(type -p ${INSTALL_CHECK[a]}) ] && INSTALL_RESULT[a]=1 || INSTALL_RESULT[a]=0
done
for ((b=0; b<${#CASE_RESAULT[@]}; b++)); do
[[ "${INSTALL_RESULT[@]}" = "${CASE_RESAULT[b]}" ]] && break
done
case "$b" in
0 ) error " $(text 150) " ;;
1|2|4 ) ${CHANGE_IP1[b]} ;;
* ) hint "\n ${SHOW_CHOOSE[b]} \n" && reading " $(text 50) " MODE
case "$MODE" in
[1-3] ) $(eval echo "\${CHANGE_IP$MODE[b]}") ;;
* ) warning " $(text 51) [1-3] "; sleep 1; change_ip ;;
esac ;;
esac
}
# 安装BBR
bbrInstall() {
echo -e "\n==============================================================\n"
info " $(text 47) "
echo -e "\n==============================================================\n"
hint " 1. $(text 48) "
[ "$OPTION" != b ] && hint " 0. $(text 49) \n" || hint " 0. $(text 76) \n"
reading " $(text 50) " BBR
case "$BBR" in
1 ) wget --no-check-certificate -N "https://raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh ;;
0 ) [ "$OPTION" != b ] && menu || exit ;;
* ) warning " $(text 51) [0-1]"; sleep 1; bbrInstall ;;
esac
}
# 关闭 WARP 网络接口,并删除 WGCF
uninstall() {
unset IP4 IP6 WAN4 WAN6 COUNTRY4 COUNTRY6 ASNORG4 ASNORG6
# 卸载 WGCF
uninstall_wgcf() {
wg-quick down wgcf >/dev/null 2>&1
systemctl disable --now wg-quick@wgcf >/dev/null 2>&1
[ $(type -p rpm) ] && rpm -e wireguard-tools 2>/dev/null
systemctl restart systemd-resolved >/dev/null 2>&1 && sleep 5
systemctl enable --now systemd-resolved >/dev/null 2>&1
rm -rf /usr/bin/wgcf /etc/wireguard /usr/bin/wireguard-go /usr/bin/warp /etc/dnsmasq.d/warp.conf /usr/bin/wireproxy /etc/local.d/wgcf.start
[ -e /etc/gai.conf ] && sed -i '/^precedence \:\:ffff\:0\:0/d;/^label 2002\:\:\/16/d' /etc/gai.conf
[ -e /usr/bin/tun.sh ] && rm -f /usr/bin/tun.sh
[ -e /etc/crontab ] && sed -i '/tun.sh/d' /etc/crontab
sed -i "/250 warp/d" /etc/iproute2/rt_tables
}
# 卸载 Linux Client
uninstall_proxy() {
warp-cli --accept-tos disconnect >/dev/null 2>&1
warp-cli --accept-tos disable-always-on >/dev/null 2>&1
warp-cli --accept-tos delete >/dev/null 2>&1
rule_del >/dev/null 2>&1
${PACKAGE_UNINSTALL[int]} cloudflare-warp 2>/dev/null
systemctl disable --now warp-svc >/dev/null 2>&1
rm -rf /usr/bin/wgcf /etc/wireguard /usr/bin/wireguard-go /usr/bin/warp
}
# 卸载 WirePorxy
uninstall_wireproxy() {
systemctl disable --now wireproxy
rm -rf /usr/bin/wgcf /etc/wireguard /usr/bin/wireguard-go /usr/bin/warp /etc/dnsmasq.d/warp.conf /usr/bin/wireproxy /lib/systemd/system/wireproxy.service
[ -e /etc/gai.conf ] && sed -i '/^precedence \:\:ffff\:0\:0/d;/^label 2002\:\:\/16/d' /etc/gai.conf
[ -e /usr/bin/tun.sh ] && rm -f /usr/bin/tun.sh && sed -i '/tun.sh/d' /etc/crontab
}
# 如已安装 warp_unlock 项目,先行卸载
[ -e /etc/wireguard/warp_unlock.sh ] && bash <(curl -sSL https://raw.githubusercontent.com/fscarmen/warp_unlock/main/unlock.sh) -U -$L
# 根据已安装情况执行卸载任务并显示结果
UNINSTALL_CHECK=("wg-quick" "warp-cli" "wireproxy")
UNINSTALL_DO=("uninstall_wgcf" "uninstall_proxy" "uninstall_wireproxy")
UNINSTALL_DEPENDENCIES=("wireguard-tools openresolv " "" " openresolv ")
UNINSTALL_NOT_ARCH=("wireguard-dkms " "" "wireguard-dkms resolvconf ")
UNINSTALL_DNSMASQ=("ipset dnsmasq resolvconf ")
UNINSTALL_RESULT=("$(text 117)" "$(text 119)" "$(text 98)")
for ((i=0; i<${#UNINSTALL_CHECK[@]}; i++)); do
[ $(type -p ${UNINSTALL_CHECK[i]}) ] && UNINSTALL_DO_LIST[i]=1 && UNINSTALL_DEPENDENCIES_LIST+=${UNINSTALL_DEPENDENCIES[i]}
[[ $SYSTEM != "Arch" && $(dkms status 2>/dev/null) =~ wireguard ]] && UNINSTALL_DEPENDENCIES_LIST+=${UNINSTALL_NOT_ARCH[i]}
[ -e /etc/dnsmasq.d/warp.conf ] && UNINSTALL_DEPENDENCIES_LIST+=${UNINSTALL_DNSMASQ[i]}
done
# 列出依赖,确认是手动还是自动卸载
UNINSTALL_DEPENDENCIES_LIST=$(echo $UNINSTALL_DEPENDENCIES_LIST | sed "s/ /\n/g" | sort -u | paste -d " " -s)
[ "$UNINSTALL_DEPENDENCIES_LIST" != '' ] && hint "\n $(text_eval 79) \n" && reading " $(text 170) " CONFIRM_UNINSTALL
# 卸载核心程序
for ((i=0; i<${#UNINSTALL_CHECK[@]}; i++)); do
[[ "${UNINSTALL_DO_LIST[i]}" = 1 ]] && ( ${UNINSTALL_DO[i]}; info " ${UNINSTALL_RESULT[i]} " )
done
# 选择自动卸载依赖执行以下
[[ "$UNINSTALL_DEPENDENCIES_LIST" != '' && "$CONFIRM_UNINSTALL" = [Yy] ]] && ( ${PACKAGE_UNINSTALL[int]} $UNINSTALL_DEPENDENCIES_LIST 2>/dev/null; info " $(text 171) \n" )
# 显示卸载结果
ip4_info; [[ "$L" = C && -n "$COUNTRY4" ]] && COUNTRY4=$(translate "$COUNTRY4")
ip6_info; [[ "$L" = C && -n "$COUNTRY6" ]] && COUNTRY6=$(translate "$COUNTRY6")
info " $(text 45)\n IPv4: $WAN4 $COUNTRY4 $ASNORG4\n IPv6: $WAN6 $COUNTRY6 $ASNORG6 "
}
# 同步脚本至最新版本
ver() {
wget -N -P /etc/wireguard https://raw.githubusercontent.com/fscarmen/warp/main/menu.sh || error " $(text 65) "
chmod +x /etc/wireguard/menu.sh
ln -sf /etc/wireguard/menu.sh /usr/bin/warp
info " $(text 64):$(grep ^VERSION /etc/wireguard/menu.sh | sed "s/.*=//g") $(text 18):$(grep "${L}\[1\]" /etc/wireguard/menu.sh | cut -d \" -f2) "
exit
}
# 由于warp bug,有时候获取不了ip地址,加入刷网络脚本手动运行,并在定时任务加设置 VPS 重启后自动运行,i=当前尝试次数,j=要尝试的次数
net() {
unset IP4 IP6 WAN4 WAN6 COUNTRY4 COUNTRY6 ASNORG4 ASNORG6 WARPSTATUS4 WARPSTATUS6 TYPE
[[ ! $(type -p wg-quick) || ! -e /etc/wireguard/wgcf.conf ]] && error " $(text 10) "
i=1; j=5
hint " $(text_eval 11)\n $(text_eval 12) "
[ "$SYSTEM" != Alpine ] && [[ $(systemctl is-active wg-quick@wgcf) != 'active' ]] && wg-quick down wgcf >/dev/null 2>&1
${SYSTEMCTL_START[int]} >/dev/null 2>&1
wg-quick up wgcf >/dev/null 2>&1
ss -nltp | grep dnsmasq >/dev/null 2>&1 && systemctl restart dnsmasq >/dev/null 2>&1
ip4_info; ip6_info
until [[ "$TRACE4$TRACE6" =~ on|plus ]]; do
(( i++ )) || true
hint " $(text_eval 12) "
${SYSTEMCTL_RESTART[int]} >/dev/null 2>&1
ss -nltp | grep dnsmasq >/dev/null 2>&1 && systemctl restart dnsmasq >/dev/null 2>&1
ip4_info; ip6_info
if [[ "$i" = "$j" ]]; then
if [ "$CHOOSE_TYPE" = 3 ]; then
unset CHOOSE_TYPE && i=0 && info " $(text 129) "
mv -f /etc/wireguard/wgcf.conf.bak /etc/wireguard/wgcf.conf
rm -f /etc/wireguard/info-temp.log
else
wg-quick down wgcf >/dev/null 2>&1
error " $(text_eval 13) "
fi
fi
done
# 判断账户类型,如果是 plus,检测剩余流量
[ -e /etc/wireguard/info.log ] && TYPE=' Teams' && grep -sq 'Device name' /etc/wireguard/info.log && TYPE='+' && check_quota
info " $(text_eval 14) "
[ "$L" = C ] && COUNTRY4=$(translate "$COUNTRY4")
[ "$L" = C ] && COUNTRY6=$(translate "$COUNTRY6")
[[ $OPTION = [on] ]] && info " IPv4:$WAN4 $WARPSTATUS4 $COUNTRY4 $ASNORG4\n IPv6:$WAN6 $WARPSTATUS6 $COUNTRY6 $ASNORG6 "
}
# WARP 开关,先检查是否已安装,再根据当前状态转向相反状态
onoff() {
[ ! $(type -p wg-quick) ] && error " $(text 155) "
[ -n "$(wg 2>/dev/null)" ] && (wg-quick down wgcf >/dev/null 2>&1; info " $(text 15) ") || net
}
# Proxy 开关,先检查是否已安装,再根据当前状态转向相反状态
proxy_onoff() {
[ ! $(type -p warp-cli) ] && error " $(text 93) "
if systemctl is-active warp-svc >/dev/null 2>&1; then
[[ ! "$(warp-cli --accept-tos settings)" =~ WarpProxy ]] && rule_del >/dev/null 2>&1
systemctl stop warp-svc
info " $(text 91) " && exit 0
else systemctl start warp-svc; sleep 2
if [[ $(warp-cli --accept-tos settings) =~ WarpProxy ]]; then
proxy_info
ACCOUNT=$(warp-cli --accept-tos account 2>/dev/null)
[[ $ACCOUNT =~ Limited ]] && AC='+' && CHECK_TYPE=1 && check_quota
[[ $(ss -nltp) =~ warp-svc ]] && info " $(text 90)\n $(text 27): $PROXYSOCKS5\n WARP$AC IPv4: $PROXYIP $PROXYCOUNTRY $PROXYASNORG "
[ -n "$QUOTA" ] && info " $(text 63): $QUOTA "
exit 0
else INTERFACE='--interface CloudflareWARP'
rule_add >/dev/null 2>&1
ip4_info
[[ "$L" = C && -n "$COUNTRY4" ]] && COUNTRY4=$(translate "$COUNTRY4")
ACCOUNT=$(warp-cli --accept-tos account 2>/dev/null)
[[ $ACCOUNT =~ Limited ]] && AC='+' && CHECK_TYPE=1 && check_quota
[[ $(ip a) =~ CloudflareWARP ]] && info " $(text 90)\n $(text_eval 169) "
[ -n "$QUOTA" ] && info " $(text 63): $QUOTA "
exit 0
fi
fi
}
# WireProxy 开关,先检查是否已安装,再根据当前状态转向相反状态
wireproxy_onoff() {
unset QUOTA
[ ! $(type -p wireproxy) ] && error " $(text 157) " || OCTEEP=1
if ss -nltp | grep wireproxy >/dev/null 2>&1; then
systemctl stop wireproxy
[[ ! $(ss -nltp) =~ wireproxy ]] && info " $(text 158) "
else
systemctl start wireproxy
sleep 1 && proxy_info
[[ $(ss -nltp) =~ wireproxy ]] && info " $(text 99)\n $(text 27): $PROXYSOCKS52\n WARP$AC2 IPv4: $PROXYIP2 $PROXYCOUNTRY2 $PROXYASNORG2 "
[ -n "$QUOTA" ] && info " $(text 25): $(grep 'Device name' /etc/wireguard/info.log | awk '{ print $NF }')\n $(text 63): $QUOTA "
fi
}
# 检查系统 WARP 单双栈情况。为了速度,先检查 WGCF 配置文件里的情况,再判断 trace
check_stack() {
if [ -e /etc/wireguard/wgcf.conf ]; then
grep -q "^#.*0\.\0\/0" /etc/wireguard/wgcf.conf && T4=0 || T4=1
grep -q "^#.*\:\:\/0" /etc/wireguard/wgcf.conf && T6=0 || T6=1
else
case "$TRACE4" in off ) T4='0' ;; 'on'|'plus' ) T4='1' ;; esac
case "$TRACE6" in off ) T6='0' ;; 'on'|'plus' ) T6='1' ;; esac
fi
CASE=("@0" "0@" "0@0" "@1" "0@1" "1@" "1@0" "1@1")
for ((m=0;m<${#CASE[@]};m++)); do [ "$T4"@"$T6" = "${CASE[m]}" ] && break; done
WARP_BEFORE=("" "" "" "WARP IPv6 only" "WARP IPv6" "WARP IPv4 only" "WARP IPv4" "$(text 70)")
WARP_AFTER1=("" "" "" "WARP IPv4" "WARP IPv4" "WARP IPv6" "WARP IPv6" "WARP IPv4")
WARP_AFTER2=("" "" "" "$(text 70)" "$(text 70)" "$(text 70)" "$(text 70)" "WARP IPv6")
TO1=("" "" "" "014" "014" "106" "106" "114")
TO2=("" "" "" "01D" "01D" "10D" "10D" "116")
SHORTCUT1=("" "" "" "(warp 4)" "(warp 4)" "(warp 6)" "(warp 6)" "(warp 4)")
SHORTCUT2=("" "" "" "(warp d)" "(warp d)" "(warp d)" "(warp d)" "(warp 6)")
# 判断用于检测 NAT VSP,以选择正确配置文件
if [ "$m" -le 3 ]; then
NAT=("0@1@" "1@0@1" "1@1@1" "0@1@1")
for ((n=0;n<${#NAT[@]};n++)); do [ "$IPV4@$IPV6@$INET4" = "${NAT[n]}" ] && break; done
NATIVE=("IPv6 only" "IPv4 only" "$(text 69)" "NAT IPv4")
CONF1=("014" "104" "114" "11N4")
CONF2=("016" "106" "116" "11N6")
CONF3=("01D" "10D" "11D" "11ND")
fi
}
# 单双栈在线互换。先看菜单是否有选择,再看传参数值,再没有显示2个可选项
stack_switch() {
# WARP 单双栈切换选项
SWITCH014='sed -i "s/#//g;s/^.*\:\:\/0/#&/g" /etc/wireguard/wgcf.conf'
SWITCH01D='sed -i "s/#//g" /etc/wireguard/wgcf.conf'
SWITCH106='sed -i "s/#//g;s/^.*0\.\0\/0/#&/g" /etc/wireguard/wgcf.conf'
SWITCH10D='sed -i "s/#//g" /etc/wireguard/wgcf.conf'
SWITCH114='sed -i "s/^.*\:\:\/0/#&/g" /etc/wireguard/wgcf.conf'
SWITCH116='sed -i "s/^.*0\.\0\/0/#&/g" /etc/wireguard/wgcf.conf'
[[ "$CLIENT" = [35] && "$SWITCHCHOOSE" = [4D] ]] && error " $(text 109) "
check_stack
if [[ "$CHOOSE1" = [12] ]]; then
TO=$(eval echo "\${TO$CHOOSE1[m]}")
elif [[ "$SWITCHCHOOSE" = [46D] ]]; then
[[ "$T4@$T6@$SWITCHCHOOSE" =~ '1@0@4'|'0@1@6'|'1@1@D' ]] && error " $(text 146) " || TO="$T4$T6$SWITCHCHOOSE"
fi
[ "${#TO}" != 3 ] && error " $(text 172) " || sh -c "$(eval echo "\$SWITCH$TO")"
${SYSTEMCTL_RESTART[int]}; sleep 1
OPTION=n && net
}
# 检测系统信息
check_system_info() {
info " $(text 37) "
# 判断 LXC、 KVM 的 Linux 版本是否小于 5.6,如是则安装 wireguard 内核模块,变量 WG=1。由于 linux 不能直接用小数作比较,所以用 (主版本号 * 100 + 次版本号 )与 506 作比较
[[ $(($(uname -r | cut -d . -f1) * 100 + $(uname -r | cut -d . -f2))) -lt 506 ]] && WG=1
# 必须加载 TUN 模块,先尝试在线打开 TUN。尝试成功放到启动项,失败作提示并退出脚本
if [ "$WG" = 1 ]; then
TUN=$(cat /dev/net/tun 2>&1 | tr 'A-Z' 'a-z')