forked from 233boy/v2ray
-
Notifications
You must be signed in to change notification settings - Fork 60
/
install.sh
2168 lines (1997 loc) · 60.8 KB
/
install.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
red='\e[91m'
green='\e[92m'
yellow='\e[93m'
magenta='\e[95m'
cyan='\e[96m'
none='\e[0m'
# Root
[[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1
cmd="apt-get"
sys_bit=$(uname -m)
if [[ $sys_bit == "i386" || $sys_bit == "i686" ]]; then
v2ray_bit="32"
elif [[ $sys_bit == "x86_64" ]]; then
v2ray_bit="64"
else
echo -e " 哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}" && exit 1
fi
# 笨笨的检测方法
if [[ -f /usr/bin/apt-get ]] || [[ -f /usr/bin/yum && -f /bin/systemctl ]]; then
if [[ -f /usr/bin/yum ]]; then
cmd="yum"
fi
if [[ -f /bin/systemctl ]]; then
systemd=true
fi
else
echo -e " 哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}" && exit 1
fi
uuid=$(cat /proc/sys/kernel/random/uuid)
old_id="23332333-2333-2333-2333-233boy233boy"
v2ray_server_config="/etc/v2ray/config.json"
v2ray_client_config="/etc/v2ray/233blog_v2ray_config.json"
backup="/etc/v2ray/233blog_v2ray_backup.conf"
transport=(
TCP
TCP_HTTP
WebSocket
"WebSocket + TLS"
mKCP
mKCP_utp
mKCP_srtp
mKCP_wechat-video
TCP_dynamicPort
TCP_HTTP_dynamicPort
WebSocket_dynamicPort
mKCP_dynamicPort
mKCP_utp_dynamicPort
mKCP_srtp_dynamicPort
mKCP_wechat-video_dynamicPort
HTTP/2
Socks5
)
ciphers=(
aes-128-cfb
aes-256-cfb
chacha20
chacha20-ietf
aes-128-gcm
aes-256-gcm
chacha20-ietf-poly1305
)
v2ray_config() {
# clear
echo
while :; do
echo -e "请选择 "$yellow"V2Ray"$none" 传输协议 [${magenta}1-${#transport[*]}$none]"
echo
for ((i = 1; i <= ${#transport[*]}; i++)); do
Stream="${transport[$i - 1]}"
if [[ "$i" -le 9 ]]; then
# echo
echo -e "$yellow $i. $none${Stream}"
else
# echo
echo -e "$yellow $i. $none${Stream}"
fi
done
echo
echo "备注1: 含有 [dynamicPort] 的即启用动态端口.."
echo "备注2: [utp | srtp | wechat-video] 分别为 伪装成 [BT下载 | 视频通话 | 微信视频通话]"
echo
read -p "$(echo -e "(默认协议: ${cyan}TCP$none)"):" v2ray_transport_opt
[ -z "$v2ray_transport_opt" ] && v2ray_transport_opt=1
case $v2ray_transport_opt in
[1-9] | 1[0-7])
echo
echo
echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport_opt - 1]}$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
v2ray_port_config
}
v2ray_port_config() {
case $v2ray_transport_opt in
[1-3] | [5-9] | 1[0-5] | 17)
local random=$(shuf -i20001-65535 -n1)
while :; do
echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port
[ -z "$v2ray_port" ] && v2ray_port=$random
case $v2ray_port in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
echo
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
if [[ $v2ray_transport_opt -ge 9 && $v2ray_transport_opt -le 15 ]]; then
v2ray_dynamic_port_start
elif [[ $v2ray_transport_opt == 17 ]]; then
socks_user_config
socks_pass_config
fi
;;
*)
tls_config
;;
esac
}
v2ray_dynamic_port_start() {
while :; do
echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(默认开始端口: ${cyan}10000$none):")" v2ray_dynamic_port_start_input
[ -z $v2ray_dynamic_port_start_input ] && v2ray_dynamic_port_start_input=10000
case $v2ray_dynamic_port_start_input in
$v2ray_port)
echo
echo " 不能和 V2Ray 端口一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
echo
echo
echo -e "$yellow V2Ray 动态端口开始 = $cyan$v2ray_dynamic_port_start_input$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
if [[ $v2ray_dynamic_port_start_input -lt $v2ray_port ]]; then
lt_v2ray_port=true
fi
v2ray_dynamic_port_end
}
v2ray_dynamic_port_end() {
while :; do
echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input
[ -z $v2ray_dynamic_port_end_input ] && v2ray_dynamic_port_end_input=20000
case $v2ray_dynamic_port_end_input in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then
echo
echo " 不能小于或等于 V2Ray 动态端口开始范围"
error
elif [ $lt_v2ray_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $v2ray_port ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 V2Ray 端口..."
error
else
echo
echo
echo -e "$yellow V2Ray 动态端口结束 = $cyan$v2ray_dynamic_port_end_input$none"
echo "----------------------------------------------------------------"
echo
break
fi
;;
*)
error
;;
esac
done
}
socks_user_config() {
while :; do
read -p "$(echo -e "请输入$yellow用户名$none...(默认用户名: ${cyan}233blog$none)"): " username
[ -z "$username" ] && username="233blog"
case $username in
*[/$]* | *\&*)
echo
echo -e " 由于这个脚本太辣鸡了..所以用户名不能包含$red / $none或$red $ $none或$red & $none这三个符号.... "
echo
error
;;
*)
echo
echo
echo -e "$yellow 用户名 = $cyan$username$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
}
socks_pass_config() {
while :; do
read -p "$(echo -e "请输入$yellow密码$none...(默认密码: ${cyan}233blog.com$none)"): " userpass
[ -z "$userpass" ] && userpass="233blog.com"
case $userpass in
*[/$]* | *\&*)
echo
echo -e " 由于这个脚本太辣鸡了..所以密码不能包含$red / $none或$red $ $none或$red & $none这三个符号.... "
echo
error
;;
*)
echo
echo
echo -e "$yellow 密码 = $cyan$userpass$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
}
tls_config() {
echo
local random=$(shuf -i20001-65535 -n1)
while :; do
echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"],不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port
[ -z "$v2ray_port" ] && v2ray_port=$random
case $v2ray_port in
80)
echo
echo " ...都说了不能选择 80 端口了咯....."
error
;;
443)
echo
echo " ..都说了不能选择 433 端口了咯....."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
echo
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
while :; do
echo
echo -e "请输入一个 $magenta正确的域名$none,一定一定一定要正确,不!能!出!错!"
read -p "(例如:233blog.com): " domain
[ -z "$domain" ] && error && continue
echo
echo
echo -e "$yellow 你的域名 = $cyan$domain$none"
echo "----------------------------------------------------------------"
break
done
get_ip
echo
echo
echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none"
echo
echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none"
echo
echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none"
echo "----------------------------------------------------------------"
echo
while :; do
read -p "$(echo -e "(是否已经正确解析: [${magenta}Y$none]):") " record
if [[ -z "$record" ]]; then
error
else
if [[ "$record" == [Yy] ]]; then
echo
echo
echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none"
echo "----------------------------------------------------------------"
echo
break
else
error
fi
fi
done
if [[ $v2ray_transport_opt -ne 16 ]]; then
auto_tls_config
else
caddy=true
install_caddy_info="打开"
fi
if [[ $caddy ]]; then
path_config_ask
fi
}
auto_tls_config() {
echo -e "
安装 Caddy 来实现 自动配置 TLS
如果你已经安装 Nginx 或 Caddy
$yellow并且..自己能搞定配置 TLS$none
那么就不需要 打开自动配置 TLS
"
echo "----------------------------------------------------------------"
echo
while :; do
read -p "$(echo -e "(是否自动配置 TLS: [${magenta}Y/N$none]):") " auto_install_caddy
if [[ -z "$auto_install_caddy" ]]; then
error
else
if [[ "$auto_install_caddy" == [Yy] ]]; then
caddy=true
install_caddy_info="打开"
echo
echo
echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none"
echo "----------------------------------------------------------------"
echo
break
elif [[ "$auto_install_caddy" == [Nn] ]]; then
install_caddy_info="关闭"
echo
echo
echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none"
echo "----------------------------------------------------------------"
echo
break
else
error
fi
fi
done
}
path_config_ask() {
echo
while :; do
echo -e "是否开启 网站伪装 和 路径分流 [${magenta}Y/N$none]"
read -p "$(echo -e "(默认: [${cyan}N$none]):")" is_path
[[ -z $is_path ]] && is_path="n"
case $is_path in
Y | y)
path_config
break
;;
N | n)
echo
echo
echo -e "$yellow 网站伪装 和 路径分流 = $cyan不想配置$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
}
path_config() {
echo
while :; do
echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可"
read -p "$(echo -e "(默认: [${cyan}233blog$none]):")" path
[[ -z $path ]] && path="233blog"
case $path in
*[/$]*)
echo
echo -e " 由于这个脚本太辣鸡了..所以分流的路径不能包含$red / $none或$red $ $none这两个符号.... "
echo
error
;;
*)
echo
echo
echo -e "$yellow 分流的路径 = ${cyan}/${path}$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
proxy_site_config
}
proxy_site_config() {
echo
while :; do
echo -e "请输入 ${magenta}一个正确的$none ${cyan}网址$none 用来作为 ${cyan}网站的伪装$none , 例如 https://liyafly.com"
echo -e "举例...你当前的域名是 $green$domain$none , 伪装的网址的是 https://liyafly.com"
echo -e "然后打开你的域名时候...显示出来的内容就是来自 https://liyafly.com 的内容"
echo -e "其实就是一个反代...明白就好..."
echo -e "如果不能伪装成功...可以使用 v2ray config 修改伪装的网址"
read -p "$(echo -e "(默认: [${cyan}https://liyafly.com$none]):")" proxy_site
[[ -z $proxy_site ]] && proxy_site="https://liyafly.com"
case $proxy_site in
*[#$]*)
echo
echo -e " 由于这个脚本太辣鸡了..所以伪装的网址不能包含$red # $none或$red $ $none这两个符号.... "
echo
error
;;
*)
echo
echo
echo -e "$yellow 伪装的网址 = ${cyan}${proxy_site}$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
}
blocked_hosts() {
echo
while :; do
echo -e "是否开启广告拦截 [${magenta}Y/N$none]"
read -p "$(echo -e "(默认 [${cyan}N$none]):")" blocked_ad
[[ -z $blocked_ad ]] && blocked_ad="n"
case $blocked_ad in
Y | y)
blocked_ad_info="开启"
is_blocked_ad=true
echo
echo
echo -e "$yellow 广告拦截 = $cyan开启$none"
echo "----------------------------------------------------------------"
echo
break
;;
N | n)
blocked_ad_info="关闭"
echo
echo
echo -e "$yellow 广告拦截 = $cyan关闭$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
}
shadowsocks_config() {
echo
while :; do
echo -e "是否配置 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]"
read -p "$(echo -e "(默认 [${cyan}N$none]):") " install_shadowsocks
[[ -z "$install_shadowsocks" ]] && install_shadowsocks="n"
if [[ "$install_shadowsocks" == [Yy] ]]; then
echo
shadowsocks=true
shadowsocks_port_config
break
elif [[ "$install_shadowsocks" == [Nn] ]]; then
break
else
error
fi
done
}
shadowsocks_port_config() {
local random=$(shuf -i20001-65535 -n1)
while :; do
echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2Ray"$none" 端口相同"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):") " ssport
[ -z "$ssport" ] && ssport=$random
case $ssport in
$v2ray_port)
echo
echo " 不能和 V2Ray 端口一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
if [[ $v2ray_transport_opt == "4" || $v2ray_transport_opt == "16" ]]; then
local tls=ture
fi
if [[ $tls && $ssport == "80" ]] || [[ $tls && $ssport == "443" ]]; then
echo
echo -e "由于你已选择了 "$green"WebSocket + TLS $none或$green HTTP/2"$none" 传输协议."
echo
echo -e "所以不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口"
error
elif [[ $v2ray_dynamic_port_start_input == $ssport || $v2ray_dynamic_port_end_input == $ssport ]]; then
local multi_port="${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}"
echo
echo " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:$multi_port"
error
elif [[ $v2ray_dynamic_port_start_input -lt $ssport && $ssport -le $v2ray_dynamic_port_end_input ]]; then
local multi_port="${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}"
echo
echo " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:$multi_port"
error
else
echo
echo
echo -e "$yellow Shadowsocks 端口 = $cyan$ssport$none"
echo "----------------------------------------------------------------"
echo
break
fi
;;
*)
error
;;
esac
done
shadowsocks_password_config
}
shadowsocks_password_config() {
while :; do
echo -e "请输入 "$yellow"Shadowsocks"$none" 密码"
read -p "$(echo -e "(默认密码: ${cyan}233blog.com$none)"): " sspass
[ -z "$sspass" ] && sspass="233blog.com"
case $sspass in
*[/$]*)
echo
echo -e " 由于这个脚本太辣鸡了..所以密码不能包含$red / $none或$red $ $none这两个符号.... "
echo
error
;;
*)
echo
echo
echo -e "$yellow Shadowsocks 密码 = $cyan$sspass$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
shadowsocks_ciphers_config
}
shadowsocks_ciphers_config() {
while :; do
echo -e "请选择 "$yellow"Shadowsocks"$none" 加密协议 [${magenta}1-${#ciphers[*]}$none]"
for ((i = 1; i <= ${#ciphers[*]}; i++)); do
ciphers_show="${ciphers[$i - 1]}"
echo
echo -e "$yellow $i. $none${ciphers_show}"
done
echo
read -p "$(echo -e "(默认加密协议: ${cyan}${ciphers[6]}$none)"):" ssciphers_opt
[ -z "$ssciphers_opt" ] && ssciphers_opt=7
case $ssciphers_opt in
[1-7])
ssciphers=${ciphers[$ssciphers_opt - 1]}
echo
echo
echo -e "$yellow Shadowsocks 加密协议 = $cyan${ssciphers}$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
pause
}
install_info() {
clear
echo
echo " ....准备安装了咯..看看有毛有配置正确了..."
echo
echo "---------- 安装信息 -------------"
echo
echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport_opt - 1]}$none"
if [[ $v2ray_transport_opt == "4" || $v2ray_transport_opt == 16 ]]; then
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
echo
echo -e "$yellow 你的域名 = $cyan$domain$none"
echo
echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none"
echo
echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none"
if [[ $is_blocked_ad ]]; then
echo
echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none"
fi
if [[ $path ]]; then
echo
echo -e "$yellow 路径分流 = ${cyan}/${path}$none"
fi
elif [[ $v2ray_transport_opt -ge 9 && $v2ray_transport_opt -le 15 ]]; then
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
echo
echo -e "$yellow V2Ray 动态端口范围 = $cyan${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}$none"
if [[ $is_blocked_ad ]]; then
echo
echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none"
fi
elif [[ $v2ray_transport_opt == 17 ]]; then
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
echo
echo -e "$yellow 用户名 = $cyan$username$none"
echo
echo -e "$yellow 密码 = $cyan$userpass$none"
if [[ $is_blocked_ad ]]; then
echo
echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none"
fi
else
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
if [[ $is_blocked_ad ]]; then
echo
echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none"
fi
fi
if [ $shadowsocks ]; then
echo
echo -e "$yellow Shadowsocks 端口 = $cyan$ssport$none"
echo
echo -e "$yellow Shadowsocks 密码 = $cyan$sspass$none"
echo
echo -e "$yellow Shadowsocks 加密协议 = $cyan${ssciphers}$none"
else
echo
echo -e "$yellow 是否配置 Shadowsocks = ${cyan}未配置${none}"
fi
echo
echo "---------- END -------------"
echo
pause
echo
}
domain_check() {
# if [[ $cmd == "yum" ]]; then
# yum install bind-utils -y
# else
# $cmd install dnsutils -y
# fi
# test_domain=$(dig $domain +short)
test_domain=$(ping $domain -c 1 | grep -oE -m1 "([0-9]{1,3}\.){3}[0-9]{1,3}")
if [[ $test_domain != $ip ]]; then
echo
echo -e "$red 检测域名解析错误....$none"
echo
echo -e " 你的域名: $yellow$domain$none 未解析到: $cyan$ip$none"
echo
echo -e " 你的域名当前解析到: $cyan$test_domain$none"
echo
echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 Status 那里点一下那图标..让它变灰"
echo
exit 1
fi
}
install_caddy() {
local caddy_tmp="/tmp/install_caddy/"
local caddy_tmp_file="/tmp/install_caddy/caddy.tar.gz"
if [[ $sys_bit == "i386" || $sys_bit == "i686" ]]; then
local caddy_download_link="https://caddyserver.com/download/linux/386?license=personal"
elif [[ $sys_bit == "x86_64" ]]; then
local caddy_download_link="https://caddyserver.com/download/linux/amd64?license=personal"
else
echo -e "$red 自动安装 Caddy 失败!不支持你的系统。$none" && exit 1
fi
mkdir -p $caddy_tmp
if ! wget --no-check-certificate -O "$caddy_tmp_file" $caddy_download_link; then
echo -e "$red 下载 Caddy 失败!$none" && exit 1
fi
tar zxf $caddy_tmp_file -C $caddy_tmp
cp -f ${caddy_tmp}caddy /usr/local/bin/
if [[ ! -f /usr/local/bin/caddy ]]; then
echo -e "$red 安装 Caddy 出错!" && exit 1
fi
setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/caddy
if [[ $systemd ]]; then
cp -f ${caddy_tmp}init/linux-systemd/caddy.service /lib/systemd/system/
# sed -i "s/www-data/root/g" /lib/systemd/system/caddy.service
systemctl enable caddy
else
cp -f ${caddy_tmp}init/linux-sysvinit/caddy /etc/init.d/caddy
# sed -i "s/www-data/root/g" /etc/init.d/caddy
chmod +x /etc/init.d/caddy
update-rc.d -f caddy defaults
fi
mkdir -p /etc/ssl/caddy
if [ -z "$(grep www-data /etc/passwd)" ]; then
useradd -M -s /usr/sbin/nologin www-data
fi
chown -R www-data.www-data /etc/ssl/caddy
mkdir -p /etc/caddy/
rm -rf $caddy_tmp
caddy_config
}
caddy_config() {
local email=$(shuf -i1-10000000000 -n1)
case $v2ray_transport_opt in
4)
if [[ $path ]]; then
cat >/etc/caddy/Caddyfile <<-EOF
$domain {
tls ${email}@gmail.com
gzip
timeouts none
proxy / $proxy_site {
without /${path}
}
proxy /${path} 127.0.0.1:${v2ray_port} {
without /${path}
websocket
}
}
EOF
else
cat >/etc/caddy/Caddyfile <<-EOF
$domain {
tls ${email}@gmail.com
timeouts none
proxy / 127.0.0.1:${v2ray_port} {
websocket
}
}
EOF
fi
;;
16)
if [[ $path ]]; then
cat >/etc/caddy/Caddyfile <<-EOF
$domain {
tls ${email}@gmail.com
gzip
timeouts none
proxy / $proxy_site {
without /${path}
}
proxy /${path} https://127.0.0.1:${v2ray_port} {
header_upstream Host {host}
header_upstream X-Forwarded-Proto {scheme}
insecure_skip_verify
}
}
EOF
else
cat >/etc/caddy/Caddyfile <<-EOF
$domain {
tls ${email}@gmail.com
timeouts none
proxy / https://127.0.0.1:${v2ray_port} {
header_upstream Host {host}
header_upstream X-Forwarded-Proto {scheme}
insecure_skip_verify
}
}
EOF
fi
;;
esac
# systemctl restart caddy
do_service restart caddy
}
install_v2ray() {
$cmd update -y
# if [[ $cmd == "apt-get" ]]; then
# $cmd install -y lrzsz git zip unzip curl wget qrencode dnsutils
# else
# $cmd install -y lrzsz git zip unzip curl wget qrencode bind-utils iptables-services
# fi
if [[ $cmd == "apt-get" ]]; then
$cmd install -y lrzsz git zip unzip curl wget qrencode libcap2-bin
else
$cmd install -y lrzsz git zip unzip curl wget qrencode libcap iptables-services
fi
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[ -d /etc/v2ray ] && rm -rf /etc/v2ray
if [[ $local_install ]]; then
if [[ ! -d $(pwd)/config ]]; then
echo
echo -e "$red 哎呀呀...安装失败了咯...$none"
echo
echo -e " 请确保你有完整的上传 233blog.com V2Ray 一键安装脚本 & 管理脚本到当前 ${green}$(pwd) $none目录下"
echo
exit 1
fi
mkdir -p /etc/v2ray/233boy/v2ray
cp -rf $(pwd)/* /etc/v2ray/233boy/v2ray
else
git clone https://github.com/233boy/v2ray /etc/v2ray/233boy/v2ray
fi
[ -d /tmp/v2ray ] && rm -rf /tmp/v2ray
mkdir -p /tmp/v2ray
v2ray_tmp_file="/tmp/v2ray/v2ray.zip"
v2ray_ver="$(curl -s https://api.github.com/repos/v2ray/v2ray-core/releases/latest | grep 'tag_name' | cut -d\" -f4)"
v2ray_download_link="https://github.com/v2ray/v2ray-core/releases/download/$v2ray_ver/v2ray-linux-${v2ray_bit}.zip"
if ! wget --no-check-certificate -O "$v2ray_tmp_file" $v2ray_download_link; then
echo -e "
$red 下载 V2Ray 失败啦..可能是你的小鸡鸡的网络太辣鸡了...重新安装也许能解决$none
" && exit 1
fi
unzip $v2ray_tmp_file -d "/tmp/v2ray/"
mkdir -p /usr/bin/v2ray
cp -f "/tmp/v2ray/v2ray-${v2ray_ver}-linux-${v2ray_bit}/v2ray" "/usr/bin/v2ray/v2ray"
chmod +x "/usr/bin/v2ray/v2ray"
cp -f "/tmp/v2ray/v2ray-${v2ray_ver}-linux-${v2ray_bit}/v2ctl" "/usr/bin/v2ray/v2ctl"
chmod +x "/usr/bin/v2ray/v2ctl"
if [[ $systemd ]]; then
cp -f "/tmp/v2ray/v2ray-${v2ray_ver}-linux-${v2ray_bit}/systemd/v2ray.service" "/lib/systemd/system/"
systemctl enable v2ray
else
apt-get install -y daemon
cp "/tmp/v2ray/v2ray-${v2ray_ver}-linux-${v2ray_bit}/systemv/v2ray" "/etc/init.d/v2ray"
chmod +x "/etc/init.d/v2ray"
update-rc.d -f v2ray defaults
fi
mkdir -p /var/log/v2ray
mkdir -p /etc/v2ray
rm -rf /tmp/v2ray
if [ $shadowsocks ]; then
if [[ $is_blocked_ad ]]; then
case $v2ray_transport_opt in
1)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/tcp_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/tcp.json"
;;
2)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/http_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/http.json"
;;
3)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/ws_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/ws.json"
;;
4)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/ws_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/ws_tls.json"
;;
5 | 6 | 7 | 8)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/kcp_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/kcp.json"
;;
9)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/tcp_ss_dynamic.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/tcp.json"
;;
10)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/http_ss_dynamic.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/http.json"
;;
11)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/ws_ss_dynamic.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/ws.json"
;;
12 | 13 | 14 | 15)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/kcp_ss_dynamic.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/kcp.json"
;;
16)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/h2_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/h2.json"
;;
17)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/blocked_hosts/server/socks_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/socks.json"
;;
esac
else
case $v2ray_transport_opt in
1)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/server/tcp_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/tcp.json"
;;
2)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/server/http_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/http.json"
;;
3)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/server/ws_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/ws.json"
;;
4)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/server/ws_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/ws_tls.json"
;;
5 | 6 | 7 | 8)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/server/kcp_ss.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/kcp.json"
;;
9)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/server/tcp_ss_dynamic.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/tcp.json"
;;
10)
v2ray_server_config_file="/etc/v2ray/233boy/v2ray/config/server/http_ss_dynamic.json"
v2ray_client_config_file="/etc/v2ray/233boy/v2ray/config/client/http.json"
;;