forked from hrostami/aio-proxy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
warp.sh
1876 lines (1875 loc) · 93.3 KB
/
warp.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
#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export LANG=en_US.UTF-8
endpoint=
red='\033[0;31m'
bblue='\033[0;34m'
yellow='\033[0;33m'
green='\033[0;32m'
plain='\033[0m'
red(){ echo -e "\033[31m\033[01m$1\033[0m";}
green(){ echo -e "\033[32m\033[01m$1\033[0m";}
yellow(){ echo -e "\033[33m\033[01m$1\033[0m";}
blue(){ echo -e "\033[36m\033[01m$1\033[0m";}
white(){ echo -e "\033[37m\033[01m$1\033[0m";}
bblue(){ echo -e "\033[34m\033[01m$1\033[0m";}
rred(){ echo -e "\033[35m\033[01m$1\033[0m";}
readtp(){ read -t5 -n26 -p "$(yellow "$1")" $2;}
readp(){ read -p "$(yellow "$1")" $2;}
[[ $EUID -ne 0 ]] && yellow "Please run the script in root mode" && exit
#[[ -e /etc/hosts ]] && grep -qE '^ *172.65.251.78 gitlab.com' /etc/hosts || echo -e '\n172.65.251.78 gitlab.com' >> /etc/ hosts
if [[ -f /etc/redhat-release ]]; then
release="Centos"
elif cat /etc/issue | grep -q -E -i "debian"; then
release="Debian"
elif cat /etc/issue | grep -q -E -i "ubuntu"; then
release="Ubuntu"
elif cat /etc/issue | grep -q -E -i "centos|red hat|redhat"; then
release="Centos"
elif cat /proc/version | grep -q -E -i "debian"; then
release="Debian"
elif cat /proc/version | grep -q -E -i "ubuntu"; then
release="Ubuntu"
elif cat /proc/version | grep -q -E -i "centos|red hat|redhat"; then
release="Centos"
else
red "Your current system is not supported, please choose to use Ubuntu, Debian, Centos system." && exit
fi
vsid=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1)
op=$(lsb_release -sd || cat /etc/redhat-release || cat /etc/os-release | grep -i pretty_name | cut -d \" -f2)
version=$(uname -r | cut -d "-" -f1)
main=$(uname -r | cut -d "." -f1)
minor=$(uname -r | cut -d "." -f2)
vi=$(systemd-detect-virt)
case "$release" in
"Centos") yumapt='yum -y';;
"Ubuntu"|"Debian") yumapt="apt-get -y";;
esac
cpujg(){
case $(uname -m) in
aarch64) cpu=arm64;;
x86_64) cpu=amd64;;
*) red "The current script does not support the $(uname -m) architecture" && exit;;
esac
}
cfwarpshow(){
insV=$(cat /root/warpip/v 2>/dev/null)
latestV=$(curl -s https://gitlab.com/rwkgyg/CFwarp/-/raw/main/version/version | awk -F "Update content" '{print $1}' | head -n 1)
if [[ -f /root/warpip/v ]]; then
if [ "$insV" = "$latestV" ]; then
echo -e "The current CFwarp script version number: ${bblue}${insV}${plain} is the latest version\n"
else
echo -e "Current CFwarp script version number: ${bblue}${insV}${plain}"
echo -e "The latest x-ui-yg script version number detected: ${yellow}${latestV}${plain}"
echo -e "${yellow}$(curl -s https://gitlab.com/rwkgyg/CFwarp/-/raw/main/version/version)${plain}"
echo -e "You can select 8 for update\n"
fi
else
echo -e "The current CFwarp script version number: ${bblue}${latestV}${plain} is the latest version\n"
fi
}
tun(){
if [[ $vi = openvz ]]; then
TUN=$(cat /dev/net/tun 2>&1)
if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then
red "Detected that TUN is not enabled, now try to add TUN support" && sleep 4
cd /dev && mkdir net && mknod net/tun c 10 200 && chmod 0666 net/tun
TUN=$(cat /dev/net/tun 2>&1)
if [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ 'in bad state' ]] && [[ ! $TUN =~ 'Die Dateizugriffsnummer ist in schlechter Verfassung' ]]; then
green "Failed to add TUN support. It is recommended to communicate with the VPS manufacturer or enable background settings" && exit
else
echo '#!/bin/bash' > /root/tun.sh && echo 'cd /dev && mkdir net && mknod net/tun c 10 200 && chmod 0666 net/tun' >> /root/tun.sh && chmod +x /root/tun.sh
grep -qE "^ *@reboot root bash /root/tun.sh >/dev/null 2>&1" /etc/crontab || echo "@reboot root bash /root/tun.sh >/dev/null 2> &1" >> /etc/crontab
green "TUN guard function has been started"
fi
fi
fi
}
nf4(){
result=`curl --connect-timeout 5 -4sSL "https://www.netflix.com/" 2>&1`
[ "$result" == "Not Available" ] && NF="Give up, Netflix does not serve the current IP area" && return
[[ "$result" == "curl"* ]] && NF="Error, cannot connect to Netflix official website" && return
result=`curl -4sL "https://www.netflix.com/title/80018499" 2>&1`
[[ "$result" == *"page-404"* || "$result" == *"NSEZ-403"* ]] && NF="Poor, the current IP cannot watch Netflix" && return
result1=`curl -4sL "https://www.netflix.com/title/70143836" 2>&1`
result2=`curl -4sL "https://www.netflix.com/title/80027042" 2>&1`
result3=`curl -4sL "https://www.netflix.com/title/70140425" 2>&1`
result4=`curl -4sL "https://www.netflix.com/title/70283261" 2>&1`
result5=`curl -4sL "https://www.netflix.com/title/70143860" 2>&1`
result6=`curl -4sL "https://www.netflix.com/title/70202589" 2>&1`
[[ "$result1" == *"page-404"* && "$result2" == *"page-404"* && "$result3" == *"page-404"* && "$result4" == *"page-404"* && "$result5" == *"page-404"* && "$result6" == *"page-404"* ]] && NF="Unfortunately, the current IP can only watch Netflix homemade movies drama" && return
NF="Congratulations, the current IP supports watching Netflix non-homemade dramas" && return
}
nf6(){
result=`curl --connect-timeout 5 -6sSL "https://www.netflix.com/" 2>&1`
[ "$result" == "Not Available" ] && NF="Give up, Netflix does not serve the current IP area" && return
[[ "$result" == "curl"* ]] && NF="Error, cannot connect to Netflix official website" && return
result=`curl -6sL "https://www.netflix.com/title/80018499" 2>&1`
[[ "$result" == *"page-404"* || "$result" == *"NSEZ-403"* ]] && NF="Poor, the current IP cannot watch Netflix" && return
result1=`curl -6sL "https://www.netflix.com/title/70143836" 2>&1`
result2=`curl -6sL "https://www.netflix.com/title/80027042" 2>&1`
result3=`curl -6sL "https://www.netflix.com/title/70140425" 2>&1`
result4=`curl -6sL "https://www.netflix.com/title/70283261" 2>&1`
result5=`curl -6sL "https://www.netflix.com/title/70143860" 2>&1`
result6=`curl -6sL "https://www.netflix.com/title/70202589" 2>&1`
[[ "$result1" == *"page-404"* && "$result2" == *"page-404"* && "$result3" == *"page-404"* && "$result4" == *"page-404"* && "$result5" == *"page-404"* && "$result6" == *"page-404"* ]] && NF="Unfortunately, the current IP can only watch Netflix homemade movies drama" && return
NF="Congratulations, the current IP supports watching Netflix non-homemade dramas" && return
}
nfs5() {
result=`curl -sx socks5h://localhost:$mport --connect-timeout 5 -4sSL "https://www.netflix.com/" 2>&1`
[ "$result" == "Not Available" ] && NF="Give up, Netflix does not serve the current IP area" && return
[[ "$result" == "curl"* ]] && NF="Error, cannot connect to Netflix official website" && return
result=`curl -sx socks5h://localhost:$mport -4sL "https://www.netflix.com/title/80018499" 2>&1`
[[ "$result" == *"page-404"* || "$result" == *"NSEZ-403"* ]] && NF="Poor, the current IP cannot watch Netflix" && return
result1=`curl -sx socks5h://localhost:$mport -4sL "https://www.netflix.com/title/70143836" 2>&1`
result2=`curl -sx socks5h://localhost:$mport -4sL "https://www.netflix.com/title/80027042" 2>&1`
result3=`curl -sx socks5h://localhost:$mport -4sL "https://www.netflix.com/title/70140425" 2>&1`
result4=`curl -sx socks5h://localhost:$mport -4sL "https://www.netflix.com/title/70283261" 2>&1`
result5=`curl -sx socks5h://localhost:$mport -4sL "https://www.netflix.com/title/70143860" 2>&1`
result6=`curl -sx socks5h://localhost:$mport -4sL "https://www.netflix.com/title/70202589" 2>&1`
[[ "$result1" == *"page-404"* && "$result2" == *"page-404"* && "$result3" == *"page-404"* && "$result4" == *"page-404"* && "$result5" == *"page-404"* && "$result6" == *"page-404"* ]] && NF="Unfortunately, the current IP can only watch Netflix homemade movies drama" && return
NF="Congratulations, the current IP supports watching Netflix non-homemade dramas" && return
}
v4v6(){
v4=$(curl -s4m5 ip.sb -k)
v6=$(curl -s6m5 ip.sb -k)
}
checkwgcf(){
wgcfv6=$(curl -s6m5 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
wgcfv4=$(curl -s4m5 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
}
warpip(){
mkdir -p /root/warpip
if [[ ! -f '/root/warpip/result.csv' ]]; then
cpujg
v4v6
if [[ -z $v4 ]]; then
wget -qO /root/warpip/ip.txt https://gitlab.com/rwkgyg/CFwarp/raw/main/point/ip6.txt
else
wget -qO /root/warpip/ip.txt https://gitlab.com/rwkgyg/CFwarp/raw/main/point/ip.txt
fi
wget -qO /root/warpip/$cpu https://gitlab.com/rwkgyg/CFwarp/raw/main/point/cpu/$cpu && chmod +x /root/warpip/$cpu
cd /root/warpip
./$cpu >/dev/null 2>&1 &
wait
cd
a=`cat /root/warpip/result.csv | awk -F, '$3!="timeout ms" {print} ' | sed -n '2p' | awk -F ',' '{print $2}'`
if [[ $a = 100.00% ]]; then
rm -rf /root/warpip/*
if [[ -z $v4 ]]; then
n=0
iplist=100
while true
do
temp[$n]=$(echo [2606:4700:d0::$(printf '%x\n' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n ' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n ' $(($RANDOM*2+$RANDOM%2)))])
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
temp[$n]=$(echo [2606:4700:d1::$(printf '%x\n' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n ' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n ' $(($RANDOM*2+$RANDOM%2)))])
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
done
while true
do
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo [2606:4700:d0::$(printf '%x\n' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n ' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n ' $(($RANDOM*2+$RANDOM%2)))])
n=$[$n+1]
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo [2606:4700:d1::$(printf '%x\n' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n ' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n' $(($RANDOM*2+$RANDOM%2))):$(printf '%x\n ' $(($RANDOM*2+$RANDOM%2)))])
n=$[$n+1]
fi
done
else
n=0
iplist=100
while true
do
temp[$n]=$(echo 162.159.192.$(($RANDOM%256)))
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
temp[$n]=$(echo 162.159.193.$(($RANDOM%256)))
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
temp[$n]=$(echo 162.159.195.$(($RANDOM%256)))
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
temp[$n]=$(echo 188.114.96.$(($RANDOM%256)))
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
temp[$n]=$(echo 188.114.97.$(($RANDOM%256)))
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
temp[$n]=$(echo 188.114.98.$(($RANDOM%256)))
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
temp[$n]=$(echo 188.114.99.$(($RANDOM%256)))
n=$[$n+1]
if [ $n -ge $iplist ]
then
break
fi
done
while true
do
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo 162.159.192.$(($RANDOM%256)))
n=$[$n+1]
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo 162.159.193.$(($RANDOM%256)))
n=$[$n+1]
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo 162.159.195.$(($RANDOM%256)))
n=$[$n+1]
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo 188.114.96.$(($RANDOM%256)))
n=$[$n+1]
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo 188.114.97.$(($RANDOM%256)))
n=$[$n+1]
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo 188.114.98.$(($RANDOM%256)))
n=$[$n+1]
fi
if [ $(echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u | wc -l) -ge $iplist ]
then
break
else
temp[$n]=$(echo 188.114.99.$(($RANDOM%256)))
n=$[$n+1]
fi
done
fi
echo ${temp[@]} | sed -e 's/ /\n/g' | sort -u>/root/warpip/ip.txt
wget -qO /root/warpip/$cpu https://gitlab.com/rwkgyg/CFwarp/raw/main/point/$cpu && chmod +x /root/warpip/$cpu
cd /root/warpip
./$cpu >/dev/null 2>&1 &
wait
cd
a=`cat /root/warpip/result.csv | awk -F, '$3!="timeout ms" {print} ' | sed -n '2p' | awk -F ',' '{print $2}'`
if [[ $a = 100.00% ]]; then
rm -rf /root/warpip/*
if [[ -z $v4 ]]; then
endpoint=[2606:4700:d0::a29f:c001]:2408
else
endpoint=162.159.193.10:1701
fi
else
endpoint=`cat /root/warpip/result.csv | awk -F, '$3!="timeout ms" {print} ' | sed -n '2p' | awk -F ',' '{print $1}'`
fi
else
endpoint=`cat /root/warpip/result.csv | awk -F, '$3!="timeout ms" {print} ' | sed -n '2p' | awk -F ',' '{print $1}'`
fi
else
a=`cat /root/warpip/result.csv | awk -F, '$3!="timeout ms" {print} ' | sed -n '2p' | awk -F ',' '{print $2}'`
if [[ $a = 100.00% ]]; then
if [[ -z $v4 ]]; then
endpoint=[2606:4700:d0::a29f:c001]:2408
else
endpoint=162.159.193.10:1701
fi
else
endpoint=`cat /root/warpip/result.csv | awk -F, '$3!="timeout ms" {print} ' | sed -n '2p' | awk -F ',' '{print $1}'`
fi
fi
}
dig9(){
if [[ -n $(grep 'DiG 9' /etc/hosts) ]]; then
echo -e "search blue.kundencontroller.de\noptions rotate\nnameserver 2a02:180:6:5::1c\nnameserver 2a02:180:6:5::4\nnameserver 2a02:180:6:5::1e\ nnameserver 2a02:180:6:5::1d" > /etc/resolv.conf
fi
}
mtuwarp(){
v4v6
yellow "Start automatically setting the best network throughput value of warp's MTU to optimize the WARP network!"
MTUy=1500
MTUc=10
if [[ -n $v6 && -z $v4 ]]; then
ping='ping6'
IP1='2606:4700:4700::1111'
IP2='2001:4860:4860::8888'
else
ping='ping'
IP1='1.1.1.1'
IP2='8.8.8.8'
fi
while true; do
if ${ping} -c1 -W1 -s$((${MTUy} - 28)) -Mdo ${IP1} >/dev/null 2>&1 || ${ping} -c1 -W1 -s$( (${MTUy} - 28)) -Mdo ${IP2} >/dev/null 2>&1; then
MTUc=1
MTUy=$((${MTUy} + ${MTUc}))
else
MTUy=$((${MTUy} - ${MTUc}))
[[ ${MTUc} = 1 ]] && break
fi
[[ ${MTUy} -le 1360 ]] && MTUy='1360' && break
done
MTU=$((${MTUy} - 80))
green "MTU optimal network throughput value = $MTU has been set"
}
WGproxy(){
bash <(curl -Ls https://gitlab.com/rwkgyg/CFwarp/-/raw/main/point/acwarp.sh)
}
xyz(){
if [[ -n $(screen -ls | grep '(Attached)' | awk '{print $1}' | awk -F "." '{print $1}') ]]; then
until [[ -z $(screen -ls | grep '(Attached)' | awk '{print $1}' | awk -F "." '{print $1}' | awk 'NR==1{print}') ]]
do
Attached=`screen -ls | grep '(Attached)' | awk '{print $1}' | awk -F "." '{print $1}' | awk 'NR==1{print}'`
screen -d $Attached
done
fi
screen -ls | awk '/\.up/ {print $1}' | cut -d "." -f 1 | xargs kill 2>/dev/null
rm -rf /root/WARP-UP.sh
cat>/root/WARP-UP.sh<<-\EOF
#!/bin/bash
red(){ echo -e "\033[31m\033[01m$1\033[0m";}
green(){ echo -e "\033[32m\033[01m$1\033[0m";}
sleep 2
checkwgcf(){
wgcfv6=$(curl -s6m5 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
wgcfv4=$(curl -s4m5 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
}
warpclose(){
wg-quick down wgcf >/dev/null 2>&1;systemctl stop wg-quick@wgcf >/dev/null 2>&1;systemctl disable wg-quick@wgcf >/dev/null 2>&1;kill -15 $ (pgrep warp-go) >/dev/null 2>&1;systemctl stop warp-go >/dev/null 2>&1;systemctl disable warp-go >/dev/null 2>&1
}
warpopen(){
wg-quick down wgcf >/dev/null 2>&1;systemctl enable wg-quick@wgcf >/dev/null 2>&1;systemctl start wg-quick@wgcf >/dev/null 2>&1;systemctl restart wg- quick@wgcf >/dev/null 2>&1;kill -15 $(pgrep warp-go) >/dev/null 2>&1;systemctl stop warp-go >/dev/null 2>&1;systemctl enable warp-go >/dev/null 2>&1;systemctl start warp-go >/dev/null 2>&1;systemctl restart warp-go >/dev/null 2>&1
}
warpre(){
i=0
while [ $i -le 4 ]; do let i++
warpopen
checkwgcf
if [[ $wgcfv4 =~ on|plus || $wgcfv6 =~ on|plus ]]; then
green "The warp after the interruption tried to obtain the IP successfully!"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] The warp after the interruption tried to obtain the IP successfully!" >> /root/warpip/warp_log.txt
break
else
red "The warp after the interruption failed to obtain the IP!"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] The warp after the interruption failed to obtain the IP!" >> /root/warpip/warp_log.txt
fi
done
checkwgcf
if [[ ! $wgcfv4 =~ on|plus && ! $wgcfv6 =~ on|plus ]]; then
warpclose
red "Due to 5 failed attempts to obtain the IP of the warp, the execution is now stopped and the warp is closed, and the VPS returns to its original IP state"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] Since 5 attempts to obtain the IP of the warp failed, the execution is now stopped and the warp is closed, and the VPS restores the original IP Status" >> /root/warpip/warp_log.txt
fi
}
while true; do
green "Check whether the warp is starting..."
wp=$(cat /root/warpip/wp.log)
if[[ $wp = w4 ]]; then
checkwgcf
if [[ $wgcfv4 =~ on|plus ]]; then
green "Congratulations! The WARP IPV4 status is running! The next round of detection will be automatically executed in 600 seconds"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] Congratulations! The WARP IPV4 status is running! The next round of detection will be automatically executed in 600 seconds" > > /root/warpip/warp_log.txt
sleep 600s
else
warpre ; green "The next round of detection will be automatically executed in 500 seconds"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] The next round of detection will be automatically executed in 500 seconds" >> /root/warpip/warp_log.txt
sleep 500s
fi
elif [[ $wp = w6 ]]; then
checkwgcf
if [[ $wgcfv6 =~ on|plus ]]; then
green "Congratulations! The WARP IPV6 status is running! The next round of detection will be automatically executed in 600 seconds"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] Congratulations! The WARP IPV6 status is running! The next round of detection will be automatically executed in 600 seconds" > > /root/warpip/warp_log.txt
sleep 600s
else
warpre ; green "The next round of detection will be automatically executed in 500 seconds"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] The next round of detection will be automatically executed in 500 seconds" >> /root/warpip/warp_log.txt
sleep 500s
fi
else
checkwgcf
if [[ $wgcfv4 =~ on|plus && $wgcfv6 =~ on|plus ]]; then
green "Congratulations! The WARP IPV4+IPV6 status is running! The next round of detection will be automatically executed in 600 seconds"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] Congratulations! The WARP IPV4+IPV6 status is running! The next round of detection will be automatically executed in 600 seconds " >> /root/warpip/warp_log.txt
sleep 600s
else
warpre ; green "The next round of detection will be automatically executed in 500 seconds"
echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] The next round of detection will be automatically executed in 500 seconds" >> /root/warpip/warp_log.txt
sleep 500s
fi
fi
done
EOF
[[ -e /root/WARP-UP.sh ]] && screen -ls | awk '/\.up/ {print $1}' | cut -d "." -f 1 | xargs kill 2>/dev/null ; screen -UdmS up bash -c '/bin/bash /root/WARP-UP.sh'
}
first4(){
[[ -e /etc/gai.conf ]] && grep -qE '^ *precedence ::ffff:0:0/96 100' /etc/gai.conf || echo 'precedence ::ffff:0:0/ 96 100' >> /etc/gai.conf 2>/dev/null
}
docker(){
if [[ -n $(ip a | grep docker) ]]; then
red "It has been detected that docker has been installed on the VPS. Please ensure that docker is in host running mode, otherwise docker will fail" && sleep 3s
echo
yellow "Continue to install WARP in plan 1 after 6 seconds. To exit the installation, please press Ctrl+c" && sleep 6s
fi
}
lncf(){
curl -sSL -o /usr/bin/cf -L https://gitlab.com/rwkgyg/CFwarp/-/raw/main/CFwarp.sh
chmod +x /usr/bin/cf
}
UPwpyg(){
if [[ ! -f '/usr/bin/cf' ]]; then
red "CFwarp script was not installed properly!" && exit
fi
lncf
curl -s https://gitlab.com/rwkgyg/CFwarp/-/raw/main/version/version | awk -F "Update content" '{print $1}' | head -n 1 > /root/warpip/v
green "CFwarp script upgraded successfully" && cf
}
restwarpgo(){
kill -15 $(pgrep warp-go) >/dev/null 2>&1 && sleep 2
systemctl restart warp-go >/dev/null 2>&1
systemctl enable warp-go >/dev/null 2>&1
systemctl start warp-go >/dev/null 2>&1
}
cso(){
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
if [[ $release = Centos ]]; then
yum autoremove cloudflare-warp -y
else
apt purge cloudflare-warp -y
rm -f /etc/apt/sources.list.d/cloudflare-client.list /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
fi
$yumapt autoremove
}
WARPun(){
readp "1. Uninstall only solution one WARP\n2. Uninstall only solution two Socks5-WARP\n3. Thoroughly clean and uninstall all WARP-related solutions (1+2)\n Please select:" cd
case "$cd" in
1) cwg && green "warp uninstall completed";;
2) cso && green "socks5-warp uninstall completed";;
3) cwg && cso && unreswarp && green "warp and socks5-warp have been completely uninstalled" && rm -rf /usr/bin/cf warp_update
esac
}
WARPtools(){
green "1. Check the WARP online monitoring status in real time (please note before entering: exit and continue to execute the monitoring command: ctrl+a+d, exit and close the monitoring command: ctrl+c)"
green "2. Restart WARP online monitoring function"
green "3. Reset and customize the WARP online monitoring time interval"
green "4. Check the WARP online monitoring log for the day"
echo "-------------------------------------------------"
green "5. Change Socks5+WARP port"
echo "-------------------------------------------------"
green "6. Use your own warp key to slowly flush warp + traffic"
green "7. Generate warp+ key with more than 20 million GB traffic in one click"
echo "-------------------------------------------------"
green "0. Exit"
readp "Please select:" warptools
if [[ $warptools == 1 ]]; then
[[ -z $(type -P warp-go) && -z $(type -P wg-quick) ]] && red "Option 1 is not installed, the script exits" && exit
name=`screen -ls | grep '(Detached)' | awk '{print $1}' | awk -F "." '{print $2}'`
if [[ $name =~ "up" ]]; then
screen -Ur up
else
red "The WARP monitoring function is not started, please select 2 to restart" && WARPtools
fi
elif [[ $warptools == 2 ]]; then
[[ -z $(type -P warp-go) && -z $(type -P wg-quick) ]] && red "Option 1 is not installed, the script exits" && exit
xyz
name=`screen -ls | grep '(Detached)' | awk '{print $1}' | awk -F "." '{print $2}'`
[[ $name =~ "up" ]] && green "WARP online monitoring started successfully" || red "WARP online monitoring failed to start, check whether screen is installed successfully"
elif [[ $warptools == 3 ]]; then
[[ -z $(type -P warp-go) && -z $(type -P wg-quick) ]] && red "Option 1 is not installed, the script exits" && exit
xyz
readp "When the warp status is running, recheck the warp status interval (default is 600 seconds when pressing Enter), please enter the interval (for example: 50 seconds, enter 50):" stop
[[ -n $stop ]] && sed -i "s/600s/${stop}s/g;s/600seconds/${stop}seconds/g" /root/WARP-UP.sh || green " The default interval is 600 seconds"
readp "When the warp status is interrupted (the warp automatically closes after 5 consecutive failures and the original VPS IP is restored), continue to detect the WARP status interval (the default is 500 seconds by pressing Enter), please enter the interval time (for example: 50 seconds, enter 50) :" goon
[[ -n $goon ]] && sed -i "s/500s/${goon}s/g;s/500 seconds/${goon} seconds/g" /root/WARP-UP.sh || green " The default interval is 500 seconds"
[[ -e /root/WARP-UP.sh ]] && screen -ls | awk '/\.up/ {print $1}' | cut -d "." -f 1 | xargs kill 2>/dev/null ; screen -UdmS up bash -c '/bin/bash /root/WARP-UP.sh'
green "Setup completed, you can view the monitoring time interval in option 1"
elif [[ $warptools == 4 ]]; then
[[ -z $(type -P warp-go) && -z $(type -P wg-quick) ]] && red "Option 1 is not installed, the script exits" && exit
cat /root/warpip/warp_log.txt
# find /root/warpip/warp_log.txt -mtime -1 -exec cat {} \;
elif [[ $warptools == 6 ]]; then
green "You can also brush it online on the web: https://replit.com/@ygkkkk/Warp" && sleep 2
wget -N https://gitlab.com/rwkgyg/CFwarp/raw/main/wp-plus.py
sed -i "27 s/[(][^)]*[)]//g" wp-plus.py
readp "Client configuration ID (36 characters):" ID
sed -i "27 s/input/'$ID'/"wp-plus.py
python3wp-plus.py
elif [[ $warptools == 5 ]]; then
SOCKS5WARPPORT
elif [[ $warptools == 7 ]]; then
wppluskey && rm -rf warpplus.sh
green "The accumulated warp+ keys generated by the current script have been placed in the /root/WARP+Keys.txt file"
green "The new key for each re-execution will be placed at the end of the file (including scheme one and scheme two)"
blue "$(cat /root/WARP+Keys.txt)"
echo
else
cf
fi
}
ShowSOCKS5(){
if [[ $(systemctl is-active warp-svc) = active ]]; then
mport=`warp-cli --accept-tos settings 2>/dev/null | grep 'WarpProxy on port' | awk -F "port " '{print $2}'`
s5ip=`curl -sx socks5h://localhost:$mport ip.sb -k`
nfs5
[[ -z $(curl -sx socks5h://localhost:$mport https://chat.openai.com/ -I | grep -w "cf-mitigated") ]] && chat='Unfortunately, the current IP cannot Access ChatGPT official website service' || chat='Congratulations, the current IP supports access to ChatGPT official website service'
#curl -sx socks5h://localhost:$mport https://chat.openai.com/ | grep -qw "Sorry, you have been blocked" && chat='Sorry, the current IP cannot access the ChatGPT official website service' || chat='Congratulations, the current IP supports access to ChatGPT official website service'
#NF=$(./nf -proxy socks5h://localhost:$mport | awk '{print $1}' | sed -n '3p')
nonf=$(curl -sx socks5h://localhost:$mport --user-agent "${UA_Browser}" http://ip-api.com/json/$s5ip?lang=zh-CN -k | cut -f2 -d"," | cut -f4 -d '"')
#sunf=$(./nf | awk '{print $1}' | sed -n '4p')
#snnf=$(curl -sx socks5h://localhost:$mport ip.p3terx.com -k | sed -n 2p | awk '{print $3}')
country=$nonf
socks5=$(curl -sx socks5h://localhost:$mport www.cloudflare.com/cdn-cgi/trace -k --connect-timeout 2 | grep warp | cut -d= -f2)
case ${socks5} in
plus)
S5Status=$(white "Socks5 WARP+ status: \c" ; rred "Running, WARP+ account (remaining WARP+ traffic: $((`warp-cli --accept-tos account | grep Quota | awk '{ print $(NF ) }'`/1000000000)) GB)" ; white " Socks5 port: \c" ; rred "$mport" ; white " Service provider Cloudflare obtains IPV4 address: \c" ; rred "$s5ip $country" ; white " Netflix NF unlocking status: \c" ; rred "$NF" ; white " ChatGPT unlocking status: \c" ; rred "$chat");;
on)
S5Status=$(white "Socks5 WARP status: \c" ; green "Running, WARP ordinary account (unlimited WARP traffic)" ; white " Socks5 port: \c" ; green "$mport" ; white " Obtained from service provider Cloudflare IPV4 address: \c" ; green "$s5ip $country" ; white " Netflix NF unlocking status: \c" ; green "$NF" ; white " ChatGPT unlocking status: \c" ; green "$chat");;
*)
S5Status=$(white "Socks5 WARP status:\c" ; yellow "Socks5-WARP client is installed, but the port is closed")
esac
else
S5Status=$(white "Socks5 WARP status: \c" ; red "Socks5-WARP client is not installed")
fi
}
SOCKS5ins(){
yellow "Detecting Socks5-WARP installation environment..."
if [[ $release = Centos ]]; then
[[ ! ${vsid} =~ 8 ]] && yellow "Current system version number: Centos $vsid \nSocks5-WARP only supports Centos 8 " && exit
elif [[ $release = Ubuntu ]]; then
[[ ! ${vsid} =~ 20|22 ]] && yellow "Current system version number: Ubuntu $vsid \nSocks5-WARP only supports Ubuntu 20.04/22.04 system" && exit
elif [[ $release = Debian ]]; then
[[ ! ${vsid} =~ 10|11|12 ]] && yellow "Current system version number: Debian $vsid \nSocks5-WARP only supports Debian 10/11/12 system" && exit
fi
[[ $(warp-cli --accept-tos status 2>/dev/null) =~ 'Connected' ]] && red "Socks5-WARP is currently running" && cf
systemctl stop wg-quick@wgcf >/dev/null 2>&1
kill -15 $(pgrep warp-go) >/dev/null 2>&1 && sleep 2
v4v6
if [[ -n $v6 && -z $v4 ]]; then
systemctl start wg-quick@wgcf >/dev/null 2>&1
restwarpgo
red "Pure IPV6 VPS currently does not support the installation of Socks5-WARP" && sleep 2 && exit
else
systemctl start wg-quick@wgcf >/dev/null 2>&1
restwarpgo
#elif [[ -n $v4 && -z $v6 ]]; then
#systemctl start wg-quick@wgcf >/dev/null 2>&1
#checkwgcf
#[[ $wgcfv4 =~ on|plus ]] && red "The pure IPV4 VPS has Wgcf-WARP-IPV4 installed and does not support the installation of Socks5-WARP" && cf
#elif [[ -n $v4 && -n $v6 ]]; then
#systemctl start wg-quick@wgcf >/dev/null 2>&1
#checkwgcf
#[[ $wgcfv4 =~ on|plus || $wgcfv6 =~ on|plus ]] && red "The native dual-stack VPS has Wgcf-WARP-IPV4/IPV6 installed, please uninstall it first. Then install Socks5-WARP, and finally install it Wgcf-WARP-IPV4/IPV6" && cf
fi
#systemctl start wg-quick@wgcf >/dev/null 2>&1
#checkwgcf
#if [[ $wgcfv4 =~ on|plus && $wgcfv6 =~ on|plus ]]; then
#red "Wgcf-WARP-IPV4+IPV6 has been installed, installation of Socks5-WARP is not supported" && cf
#fi
if [[ $release = Centos ]]; then
if [[ ${vsid} =~ 8 ]]; then
yum clean all && yum makecache
fi
yum -y install epel-release && yum -y install net-tools
curl -fsSl https://pkg.cloudflareclient.com/cloudflare-warp-ascii.repo | tee /etc/yum.repos.d/cloudflare-warp.repo
yum update
#rpm -ivh https://pkg.cloudflareclient.com/cloudflare-release-el8.rpm
yum -y install cloudflare-warp
fi
if [[ $release = Debian ]]; then
[[ ! $(type -P gpg) ]] && apt update && apt install gnupg -y
[[ ! $(apt list 2>/dev/null | grep apt-transport-https | grep installed) ]] && apt update && apt install apt-transport-https -y
fi
if [[ $release != Centos ]]; then
apt install net-tools -y
curl https://pkg.cloudflareclient.com/pubkey.gpg | gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] http://pkg.cloudflareclient.com/ $(lsb_release -sc) main" | tee /etc /apt/sources.list.d/cloudflare-client.list
apt update;apt install cloudflare-warp -y
fi
warpip
warp-cli --accept-tos register >/dev/null 2>&1 && sleep 2
warp-cli --accept-tos set-mode proxy >/dev/null 2>&1
warp-cli --accept-tos set-custom-endpoint "$endpoint" >/dev/null 2>&1
warp-cli --accept-tos connect >/dev/null 2>&1
warp-cli --accept-tos enable-always-on >/dev/null 2>&1
wppluskey >/dev/null 2>&1
ID=$(tail -n1 /root/WARP+Keys.txt | cut -d' ' -f1 2>/dev/null)
if [[ -n $ID ]]; then
green "use warp+key"
green "$(tail -n1 /root/WARP+Keys.txt | cut -d' ' -f1)"
warp-cli --accept-tos set-license $ID >/dev/null 2>&1
fi
rm -rf warpplus.sh
if [[ $(warp-cli --accept-tos account) =~ 'Limited' ]]; then
green "Upgraded to Socks5-WARP+ account\nSocks5-WARP+ account remaining traffic: $((`warp-cli --accept-tos account | grep Quota | awk '{ print $(NF) }'`/1000000000)) GB "
fi
sleep 2 && lncf && reswarp && cf
}
SOCKS5WARPUP(){
[[ ! $(type -P warp-cli) ]] && red "Socks5-WARP is not installed and cannot be upgraded to Socks5-WARP+ account" && exit
[[ $(warp-cli --accept-tos account) =~ 'Limited' ]] && red "It is already a Socks5-WARP+ account, no need to upgrade" && exit
readp "Button license key (26 characters):" ID
[[ -n $ID ]] && warp-cli --accept-tos set-license $ID >/dev/null 2>&1 || (red "No key license key entered (26 characters)" && exit )
yellow "If it prompts Error: Too many devices. It may be that the number of bound devices exceeds the limit of 5 or the key is entered incorrectly"
if [[ $(warp-cli --accept-tos account) =~ 'Limited' ]]; then
green "Upgraded to Socks5-WARP+ account\nSocks5-WARP+ account remaining traffic: $((`warp-cli --accept-tos account | grep Quota | awk '{ print $(NF) }'`/1000000000)) GB "
else
red "Failed to upgrade Socks5-WARP+ account" && exit
fi
sleep 2 && ShowSOCKS5 && S5menu
}
SOCKS5WARPPORT(){
[[ ! $(type -P warp-cli) ]] && red "Socks5-WARP(+) is not installed and the port cannot be changed" && exit
readp "Please enter the custom socks5 port [2000~65535] (press Enter to skip to a random port between 2000-65535):" port
if [[ -z $port ]]; then
port=$(shuf -i 2000-65535 -n 1)
until [[ -z $(ss -ntlp | awk '{print $4}' | sed 's/.*://g' | grep -w "$port") ]]
do
[[ -n $(ss -ntlp | awk '{print $4}' | sed 's/.*://g' | grep -w "$port") ]] && yellow "\nThe port is occupied, please Re-enter the port" && readp "Custom socks5 port:" port
done
else
until [[ -z $(ss -ntlp | awk '{print $4}' | sed 's/.*://g' | grep -w "$port") ]]
do
[[ -n $(ss -ntlp | awk '{print $4}' | sed 's/.*://g' | grep -w "$port") ]] && yellow "\nThe port is occupied, please Re-enter the port" && readp "Custom socks5 port:" port
done
fi
[[ -n $port ]] && warp-cli --accept-tos set-proxy-port $port >/dev/null 2>&1
green "Current socks5 port: $port"
sleep 2 && ShowSOCKS5 && S5menu
}
WGCFmenu(){
name=`screen -ls | grep '(Detached)' | awk '{print $1}' | awk -F "." '{print $2}'`
[[ $name =~ "up" ]] && keepup="WARP monitoring is on" || keepup="WARP monitoring is off"
white "-----------------------------------------------------------------------------------"
white "Option 1: The current IPV4 takeover VPS outbound situation is as follows ($keepup)"
white " ${WARPIPv4Status}"
white "-----------------------------------------------------------------------------------"
white "Option 1: The current IPV6 takeover VPS outbound situation is as follows ($keepup)"
white " ${WARPIPv6Status}"
white "-----------------------------------------------------------------------------------"
if [[ "$WARPIPv4Status" == *"does not exist"* && "$WARPIPv6Status" == *"does not exist"* ]]; then
yellow "Both IPV4 and IPV6 do not exist! It is recommended to use the cf shortcut to enter again after exiting. If it persists, it is recommended to uninstall and reinstall solution one"
fi
}
S5menu(){
white "-----------------------------------------------------------------------------------------"
white "Option 2: The current Socks5-WARP official client local agent situation is as follows"
blue " ${S5Status}"
white "-----------------------------------------------------------------------------------------"
}
reswarp(){
unreswarp
crontab -l > /tmp/crontab.tmp
echo "0 4 * * * systemctl stop warp-go;systemctl restart warp-go;systemctl restart wg-quick@wgcf;systemctl restart warp-svc" >> /tmp/crontab.tmp
echo "@reboot screen -UdmS up /bin/bash /root/WARP-UP.sh" >> /tmp/crontab.tmp
echo "0 0 * * * rm -f /root/warpip/warp_log.txt" >> /tmp/crontab.tmp
crontab /tmp/crontab.tmp
rm /tmp/crontab.tmp
}
unreswarp(){
crontab -l > /tmp/crontab.tmp
sed -i '/systemctl stop warp-go;systemctl restart warp-go;systemctl restart wg-quick@wgcf;systemctl restart warp-svc/d' /tmp/crontab.tmp
sed -i '/@reboot screen/d' /tmp/crontab.tmp
sed -i '/warp_log.txt/d' /tmp/crontab.tmp
crontab /tmp/crontab.tmp
rm /tmp/crontab.tmp
}
wppluskey(){
if [[ $cpu = amd64 ]]; then
curl -sSL -o warpplus.sh --insecure https://gitlab.com/rwkgyg/CFwarp/-/raw/main/point/warpplus.sh >/dev/null 2>&1
elif [[ $cpu = arm64 ]]; then
curl -sSL -o warpplus.sh --insecure https://gitlab.com/rwkgyg/CFwarp/-/raw/main/point/warpplusa.sh >/dev/null 2>&1
fi
chmod +x warpplus.sh
timeout 60s ./warpplus.sh
}
ONEWARPGO(){
yellow "\n Please wait, it is currently in warp-go core installation mode, detecting outbound and unlocking..."
warpip
wgo1='sed -i "s#.*AllowedIPs.*#AllowedIPs = 0.0.0.0/0#g" /usr/local/bin/warp.conf'
wgo2='sed -i "s#.*AllowedIPs.*#AllowedIPs = ::/0#g" /usr/local/bin/warp.conf'
wgo3='sed -i "s#.*AllowedIPs.*#AllowedIPs = 0.0.0.0/0,::/0#g" /usr/local/bin/warp.conf'
wgo4='sed -i "/Endpoint6/d" /usr/local/bin/warp.conf && sed -i "/Endpoint/s/.*/Endpoint = '"$endpoint"'/" /usr/local/ bin/warp.conf'
wgo5='sed -i "/Endpoint6/d" /usr/local/bin/warp.conf && sed -i "/Endpoint/s/.*/Endpoint = '"$endpoint"'/" /usr/local/ bin/warp.conf'
wgo6='sed -i "/\[Script\]/a PostUp = ip -4 rule add from $(ip route get 162.159.192.1 | grep -oP "src \K\S+") lookup main\n" /usr /local/bin/warp.conf && sed -i "/\[Script\]/a PostDown = ip -4 rule delete from $(ip route get 162.159.192.1 | grep -oP "src \K\S+") lookup main\n" /usr/local/bin/warp.conf'
wgo7='sed -i "/\[Script\]/a PostUp = ip -6 rule add from $(ip route get 2606:4700:d0::a29f:c001 | grep -oP "src \K\S+") lookup main\n" /usr/local/bin/warp.conf && sed -i "/\[Script\]/a PostDown = ip -6 rule delete from $(ip route get 2606:4700:d0::a29f:c001 | grep -oP "src \K\S+") lookup main\n" /usr/local/bin/warp.conf '
wgo8='sed -i "/\[Script\]/a PostUp = ip -4 rule add from $(ip route get 162.159.192.1 | grep -oP "src \K\S+") lookup main\n" /usr /local/bin/warp.conf && sed -i "/\[Script\]/a PostDown = ip -4 rule delete from $(ip route get 162.159.192.1 | grep -oP "src \K\S+") lookup main\n" /usr/local/bin/warp.conf && sed -i "/\[Script\]/a PostUp = ip -6 rule add from $(ip route get 2606:4700:d0::a29f:c001 | grep -oP "src \K\S+") lookup main\n" /usr/local/bin/warp.conf && sed -i "/\[Script\]/a PostDown = ip -6 rule delete from $( ip route get 2606:4700:d0::a29f:c001 | grep -oP "src \K\S+") lookup main\n" /usr/local/bin/warp.conf'
STOPwgcf(){
if [[ -n $(type -P warp-cli) ]]; then
red "Socks5-WARP has been installed and the currently selected WARP installation solution is not supported"
systemctl restart warp-go && cf
fi
}
ShowWGCF(){
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"
v4v6
warppflow=$((`grep -oP '"quota":\K\d+' <<< $(curl -sm4 "https://api.cloudflareclient.com/v0a884/reg/$(grep 'Device' /usr /local/bin/warp.conf 2>/dev/null | cut -d= -f2 | sed 's# ##g')" -H "User-Agent: okhttp/3.12.1" -H "Authorization: Bearer $(grep 'Token' /usr/local/bin/warp.conf 2>/dev/null | cut -d= -f2 | sed 's# ##g')")`))
flow=`echo "scale=2; $warppflow/1000000000" | bc`
[[ -e /usr/local/bin/warpplus.log ]] && cfplus="WARP+ account (limited WARP+ traffic: $flow GB), device name: $(sed -n 1p /usr/local/bin/warpplus. log)" || cfplus="WARP+Teams account (unlimited WARP+traffic)"
if [[ -n $v4 ]]; then
nf4
[[ -z $(curl -s4 https://chat.openai.com/ -I | grep -w "cf-mitigated") ]] && chat='Unfortunately, the current IP cannot access the ChatGPT official website service' || chat ='Congratulations, the current IP supports access to ChatGPT official website service'
#curl -s4 "https://chat.openai.com/" | grep -qw "Sorry, you have been blocked" && chat='Sorry, the current IP cannot access the ChatGPT official website service' || chat='Congratulations, currently IP supports access to ChatGPT official website service'
#[[ $(curl -s4 https://chat.openai.com/ -I | grep "text/plain") != "" ]] && chat='Unfortunately, the current IP cannot access the ChatGPT official website service' || chat='Congratulations, the current IP supports access to ChatGPT official website service'
wgcfv4=$(curl -s4 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
isp4a=`curl -sm3 --user-agent "${UA_Browser}" http://ip-api.com/json/$v4?lang=zh-CN -k | cut -f13 -d ":" | cut -f2 -d '"'`
isp4b=`curl -sm3 --user-agent "${UA_Browser}" https://api.ip.sb/geoip/$v4 -k | awk -F "isp" '{print $2}' | awk -F "offset" '{print $1}' | sed "s/[,\":]//g"`
[[ -n $isp4a ]] && isp4=$isp4a || isp4=$isp4b
nonf=$(curl -sm3 --user-agent "${UA_Browser}" http://ip-api.com/json/$v4?lang=zh-CN -k | cut -f2 -d"," | cut -f4 -d '"')
#sunf=$(./nf | awk '{print $1}' | sed -n '4p')
#snnf=$(curl -s4m6 ip.p3terx.com -k | sed -n 2p | awk '{print $3}')
country=$nonf
case ${wgcfv4} in
plus)
WARPIPv4Status=$(white "WARP+ status: \c" ; rred "Running, $cfplus" ; white " Service provider Cloudflare obtains IPV4 address: \c" ; rred "$v4 $country" ; white " Netflix NF unlocking status :\c" ; rred "$NF" ; white " ChatGPT unlocking situation:\c" ; rred "$chat");;
on)
WARPIPv4Status=$(white "WARP status:\c" ; green "Running, WARP ordinary account (unlimited WARP traffic)" ; white "Service provider Cloudflare obtains IPV4 address:\c" ; green "$v4 $country" ; white " Netflix NF unlocking status: \c" ; green "$NF" ; white " ChatGPT unlocking status: \c" ; green "$chat");;
off)
WARPIPv4Status=$(white "WARP status:\c" ; yellow "Close" ; white " Service provider $isp4 obtains IPV4 address:\c" ; yellow "$v4 $country" ; white " Netflix NF unlocking status:\ c" ; yellow "$NF" ; white " ChatGPT unlocking status:\c" ; yellow "$chat");;
esac
else
WARPIPv4Status=$(white "IPV4 status:\c" ; red "IPV4 address does not exist")
fi
if [[ -n $v6 ]]; then
nf6
[[ -z $(curl -s6 https://chat.openai.com/ -I | grep -w "cf-mitigated") ]] && chat='Unfortunately, the current IP cannot access the ChatGPT official website service' || chat ='Congratulations, the current IP supports access to ChatGPT official website service'
#curl -s6 "https://chat.openai.com/" | grep -qw "Sorry, you have been blocked" && chat='Unfortunately, the current IP cannot access the ChatGPT official website service' || chat='Congratulations, currently IP supports access to ChatGPT official website service'
#[[ $(curl -s6 https://chat.openai.com/ -I | grep "text/plain") != "" ]] && chat='Unfortunately, the current IP cannot access the ChatGPT official website service' || chat='Congratulations, the current IP supports access to ChatGPT official website service'
wgcfv6=$(curl -s6 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
isp6a=`curl -sm3 --user-agent "${UA_Browser}" http://ip-api.com/json/$v6?lang=zh-CN -k | cut -f13 -d":" | cut -f2 -d '"'`
isp6b=`curl -sm3 --user-agent "${UA_Browser}" https://api.ip.sb/geoip/$v6 -k | awk -F "isp" '{print $2}' | awk -F "offset" '{print $1}' | sed "s/[,\":]//g"`
[[ -n $isp6a ]] && isp6=$isp6a || isp6=$isp6b
nonf=$(curl -sm3 --user-agent "${UA_Browser}" http://ip-api.com/json/$v6?lang=zh-CN -k | cut -f2 -d"," | cut -f4 -d '"')
#sunf=$(./nf | awk '{print $1}' | sed -n '8p')
#snnf=$(curl -s6m6 ip.p3terx.com -k | sed -n 2p | awk '{print $3}')
country=$nonf
case ${wgcfv6} in
plus)
WARPIPv6Status=$(white "WARP+ status: \c" ; rred "Running, $cfplus" ; white " Service provider Cloudflare obtained IPV6 address: \c" ; rred "$v6 $country" ; white " Netflix NF unlocking status :\c" ; rred "$NF" ; white " ChatGPT unlocking situation:\c" ; rred "$chat");;
on)
WARPIPv6Status=$(white "WARP status:\c" ; green "Running, WARP ordinary account (unlimited WARP traffic)" ; white "Service provider Cloudflare obtains IPV6 address:\c" ; green "$v6 $country" ; white " Netflix NF unlocking status: \c" ; green "$NF" ; white " ChatGPT unlocking status: \c" ; green "$chat");;
off)
WARPIPv6Status=$(white "WARP status:\c" ; yellow "Closing" ; white " Service provider $isp6 obtains IPV6 address: \c" ; yellow "$v6 $country" ; white " Netflix NF unlocking status: \c" ; yellow "$NF" ; white " ChatGPT unlocking Case: \c" ; yellow "$chat");;
esac
else
WARPIPv6Status=$(white "IPV6 status: \c" ; red "IPV6 address does not exist ")
fi
}
CheckWARP(){
i=0
while [ $i -le 9 ]; do let i++
yellow "Executed 10 times in total, the IP of the warp is obtained for the $ith time..."
restwarpgo
checkwgcf
if [[ $wgcfv4 =~ on|plus || $wgcfv6 =~ on|plus ]]; then
green "Congratulations! Warp's IP was obtained successfully!" && dns
break
else
red "Sorry! Warp's IP acquisition failed"
fi
done
if [[ ! $wgcfv4 =~ on|plus && ! $wgcfv6 =~ on|plus ]]; then
red "Failed to install WARP, restore VPS, uninstall WARP"
cwg
echo
[[ $release = Centos && ${vsid} -lt 7 ]] && yellow "Current system version number: Centos $vsid \nIt is recommended to use Centos 7 or above system"
[[ $release = Ubuntu && ${vsid} -lt 18 ]] && yellow "Current system version number: Ubuntu $vsid \nIt is recommended to use Ubuntu 18 or above system"
[[ $release = Debian && ${vsid} -lt 10 ]] && yellow "Current system version number: Debian $vsid \nIt is recommended to use Debian 10 or above system"
yellow "Tip:"
red "You may be able to use option 2 or 3 to implement WARP"
red "You can also choose WGCF core to install WARP solution one"
exit
else
green "ok" && systemctl restart warp-go
fi
}
nat4(){
[[ -n $(ip route get 1.1.1.1 2>/dev/null | grep -oP 'src \K\S+') ]] && wpgo4=$wgo6 || wpgo4=echo
}
WGCFv4(){
yellow "Wait for 3 seconds to detect the warp environment in the VPS"
docker && checkwgcf
if [[ ! $wgcfv4 =~ on|plus && ! $wgcfv6 =~ on|plus ]]; then
v4v6
if [[ -n $v4 && -n $v6 ]]; then
green "The current native v4+v6 dual-stack vps is installed for the first time warp-go\nNow add WARP IPV4 (IP outbound performance: native IPV6 + WARP IPV4)" && sleep 2
wpgo1=$wgo1 && wpgo2=$wgo4 && wpgo3=$wgo8 && WGCFins
fi
if [[ -n $v6 && -z $v4 ]]; then
green "The current native v6 single-stack vps is installed for the first time warp-go\nNow add WARP IPV4 (IP outbound performance: native IPV6 + WARP IPV4)" && sleep 2
wpgo1=$wgo1 && wpgo2=$wgo5 && wpgo3=$wgo7 && nat4 && WGCFins
fi
if [[ -z $v6 && -n $v4 ]]; then
green "The current native v4 single-stack vps is the first installation of warp-go\nNow add WARP IPV4 (IP outbound performance: only WARP IPV4)" && sleep 2
wpgo1=$wgo1 && wpgo2=$wgo4 && wpgo3=$wgo6 && WGCFins
fi
echo 'w4' > /root/warpip/wp.log && xyz && WGCFmenu
first4
else
kill -15 $(pgrep warp-go) >/dev/null 2>&1
sleep 2 && v4v6
if [[ -n $v4 && -n $v6 ]]; then
green "The current native v4+v6 dual-stack vps has installed warp-go\nNow quickly switch to WARP IPV4 (IP outbound performance: native IPV6 + WARP IPV4)" && sleep 2
wpgo1=$wgo1 && ABC
fi
if [[ -n $v6 && -z $v4 ]]; then
green "The current native v6 single-stack vps has installed warp-go\nNow quickly switch to WARP IPV4 (IP outbound performance: native IPV6 + WARP IPV4)" && sleep 2
wpgo1=$wgo1 && ABC
fi
if [[ -z $v6 && -n $v4 ]]; then
green "The current native v4 single-stack vps has installed warp-go\nNow quickly switch to WARP IPV4 (IP outbound performance: only WARP IPV4)" && sleep 2
wpgo1=$wgo1 && ABC
fi
echo 'w4' > /root/warpip/wp.log
cat /usr/local/bin/warp.conf && sleep 2
CheckWARP && first4 && ShowWGCF && WGCFmenu
fi
}
WGCFv6(){
yellow "Wait for 3 seconds to detect the warp environment in the VPS"
docker && checkwgcf
if [[ ! $wgcfv4 =~ on|plus && ! $wgcfv6 =~ on|plus ]]; then
v4v6
if [[ -n $v4 && -n $v6 ]]; then
green "The current native v4+v6 dual-stack vps is installed for the first time warp-go\nNow add WARP IPV6 (IP outbound performance: native IPV4 + WARP IPV6)" && sleep 2
wpgo1=$wgo2 && wpgo2=$wgo4 && wpgo3=$wgo8 && WGCFins
fi
if [[ -n $v6 && -z $v4 ]]; then
green "The current native v6 single-stack vps is the first installation of warp-go\nNow add WARP IPV6 (IP outbound performance: only WARP IPV6)" && sleep 2
wpgo1=$wgo2 && wpgo2=$wgo5 && wpgo3=$wgo7 && nat4 && WGCFins
fi
if [[ -z $v6 && -n $v4 ]]; then
green "The current native v4 single-stack vps is installed for the first time with warp-go\nNow adding WARP IPV6 (IP outbound performance: native IPV4 + WARP IPV6)" && sleep 2
wpgo1=$wgo2 && wpgo2=$wgo4 && wpgo3=$wgo6 && WGCFins
fi
echo 'w6' > /root/warpip/wp.log && xyz && WGCFmenu
first4
else
kill -15 $(pgrep warp-go) >/dev/null 2>&1
sleep 2 && v4v6
if [[ -n $v4 && -n $v6 ]]; then
green "The current native v4+v6 dual-stack vps has installed warp-go\nNow quickly switch to WARP IPV6 (IP outbound performance: native IPV4 + WARP IPV6)" && sleep 2
wpgo1=$wgo2 && ABC
fi
if [[ -n $v6 && -z $v4 ]]; then
green "The current native v6 single-stack vps has installed warp-go\nNow quickly switch to WARP IPV6 (IP outbound performance: only WARP IPV6)" && sleep 2
wpgo1=$wgo2 && ABC
fi
if [[ -z $v6 && -n $v4 ]]; then
green "The current native v4 single-stack vps has installed warp-go\nNow quickly switch to WARP IPV6 (IP outbound performance: native IPV4 + WARP IPV6)" && sleep 2
wpgo1=$wgo2 && ABC
fi
echo 'w6' > /root/warpip/wp.log
cat /usr/local/bin/warp.conf && sleep 2
CheckWARP && first4 && ShowWGCF && WGCFmenu
fi
}
WGCFv4v6(){
yellow "Wait for 3 seconds to detect the warp environment in the VPS"
docker && checkwgcf
if [[ ! $wgcfv4 =~ on|plus && ! $wgcfv6 =~ on|plus ]]; then
v4v6
if [[ -n $v4 && -n $v6 ]]; then
green "The current native v4+v6 dual-stack vps is installed for the first time warp-go\nNow add WARP IPV4+IPV6 (IP outbound performance: WARP dual-stack IPV4 + IPV6)" && sleep 2
wpgo1=$wgo3 && wpgo2=$wgo4 && wpgo3=$wgo8 && WGCFins
fi
if [[ -n $v6 && -z $v4 ]]; then
green "The current native v6 single-stack vps is installed for the first time warp-go\nNow add WARP IPV4+IPV6 (IP outbound performance: WARP dual-stack IPV4 + IPV6)" && sleep 2
wpgo1=$wgo3 && wpgo2=$wgo5 && wpgo3=$wgo7 && nat4 && WGCFins
fi
if [[ -z $v6 && -n $v4 ]]; then
green "The current native v4 single stack vps is installed for the first time warp-go\nNow add WARP IPV4+IPV6 (IP outbound performance: WARP dual stack IPV4 + IPV6)" && sleep 2
wpgo1=$wgo3 && wpgo2=$wgo4 && wpgo3=$wgo6 && WGCFins
fi
echo 'w64' > /root/warpip/wp.log && xyz && WGCFmenu
first4
else
kill -15 $(pgrep warp-go) >/dev/null 2>&1
sleep 2 && v4v6
if [[ -n $v4 && -n $v6 ]]; then
green "The current native v4+v6 dual-stack vps has installed warp-go\nNow quickly switch to WARP IPV4+IPV6 (IP outbound performance: WARP dual-stack IPV4 + IPV6)" && sleep 2
wpgo1=$wgo3 && ABC
fi
if [[ -n $v6 && -z $v4 ]]; then
green "The current native v6 single-stack vps has installed warp-go\nNow quickly switch to WARP IPV4+IPV6 (IP outbound performance: WARP dual-stack IPV4 + IPV6)" && sleep 2
wpgo1=$wgo3 && ABC
fi
if [[ -z $v6 && -n $v4 ]]; then
green "The current native v4 single-stack vps has installed warp-go\nNow quickly switch to WARP IPV4+IPV6 (IP outbound performance: WARP dual-stack IPV4 + IPV6)" && sleep 2
wpgo1=$wgo3 && ABC
fi
echo 'w64' > /root/warpip/wp.log
cat /usr/local/bin/warp.conf && sleep 2
CheckWARP && first4 && ShowWGCF && WGCFmenu
fi
}
ABC(){
echo $wpgo1 | sh
echo $wpgo2 | sh
echo $wpgo3 | sh
echo $wpgo4 | sh
}
dns(){
if [[ ! -f /etc/resolv.conf.bak ]]; then
mv /etc/resolv.conf /etc/resolv.conf.bak
rm -rf /etc/resolv.conf
cp -f /etc/resolv.conf.bak /etc/resolv.conf
chattr +i /etc/resolv.conf >/dev/null 2>&1
else
chattr +i /etc/resolv.conf >/dev/null 2>&1
fi
}
WGCFins(){
if [[ $release = Centos ]]; then
if [[ ${vsid} =~ 8 ]]; then
yum clean all && yum makecache
fi
yum install epel-release -y;yum install iproute iputils-ping -y
elif [[ $release = Debian ]]; then
apt install lsb-release -y
echo "deb http://deb.debian.org/debian $(lsb_release -sc)-backports main" | tee /etc/apt/sources.list.d/backports.list
apt update -y;apt install iproute2 openresolv dnsutils iputils-ping -y
elif [[ $release = Ubuntu ]]; then
apt update -y;apt install iproute2 openresolv dnsutils iputils-ping -y
fi
wget -N https://gitlab.com/rwkgyg/CFwarp/-/raw/main/warp-go_1.0.8_linux_${cpu} -O /usr/local/bin/warp-go && chmod +x /usr/ local/bin/warp-go
yellow "Applying for WARP ordinary account, please wait!"
curl -L -o /usr/local/bin/warp.conf --retry 2 https://api.zeroteam.top/warp?format=warp-go
if [[ ! -s /usr/local/bin/warp.conf ]]; then
cpujg
curl -L -o warpapi -# --retry 2 https://gitlab.com/rwkgyg/CFwarp/-/raw/main/point/cpu1/$cpu
chmod +x warpapi
output=$(./warpapi)
private_key=$(echo "$output" | awk -F ': ' '/private_key/{print $2}')
device_id=$(echo "$output" | awk -F ': ' '/device_id/{print $2}')
warp_token=$(echo "$output" | awk -F ': ' '/token/{print $2}')
rm -rf warpapi
cat > /usr/local/bin/warp.conf <<EOF
[Account]
Device = $device_id
PrivateKey = $private_key
Token = $warp_token
Type = free
Name=WARP
MTU = 1280