释放双眼,带上耳机,听听看~!
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123 1#!/bin/bash
2
3red='\e[91m'
4green='\e[92m'
5yellow='\e[93m'
6magenta='\e[95m'
7cyan='\e[96m'
8none='\e[0m'
9_red() { echo -e ${red}$*${none}; }
10_green() { echo -e ${green}$*${none}; }
11_yellow() { echo -e ${yellow}$*${none}; }
12_magenta() { echo -e ${magenta}$*${none}; }
13_cyan() { echo -e ${cyan}$*${none}; }
14
15# Root
16[[ $(id -u) != 0 ]] && echo -e "\n 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}\n" && exit 1
17
18cmd="apt-get"
19
20sys_bit=$(uname -m)
21
22case $sys_bit in
23i[36]86)
24 v2ray_bit="32"
25 caddy_arch="386"
26 ;;
27x86_64)
28 v2ray_bit="64"
29 caddy_arch="amd64"
30 ;;
31*armv6*)
32 v2ray_bit="arm"
33 caddy_arch="arm6"
34 ;;
35*armv7*)
36 v2ray_bit="arm"
37 caddy_arch="arm7"
38 ;;
39*aarch64* | *armv8*)
40 v2ray_bit="arm64"
41 caddy_arch="arm64"
42 ;;
43*)
44 echo -e "
45 哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}
46
47 备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
48 " && exit 1
49 ;;
50esac
51
52# 笨笨的检测方法
53if [[ $(command -v apt-get) || $(command -v yum) ]] && [[ $(command -v systemctl) ]]; then
54
55 if [[ $(command -v yum) ]]; then
56
57 cmd="yum"
58
59 fi
60
61else
62
63 echo -e "
64 哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}
65
66 备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
67 " && exit 1
68
69fi
70
71uuid=$(cat /proc/sys/kernel/random/uuid)
72old_id="e55c8d17-2cf3-b21a-bcf1-eeacb011ed79"
73v2ray_server_config="/etc/v2ray/config.json"
74v2ray_client_config="/etc/v2ray/233blog_v2ray_config.json"
75backup="/etc/v2ray/233blog_v2ray_backup.conf"
76_v2ray_sh="/usr/local/sbin/v2ray"
77systemd=true
78# _test=true
79
80transport=(
81 TCP
82 TCP_HTTP
83 WebSocket
84 "WebSocket + TLS"
85 HTTP/2
86 mKCP
87 mKCP_utp
88 mKCP_srtp
89 mKCP_wechat-video
90 mKCP_dtls
91 mKCP_wireguard
92 QUIC
93 QUIC_utp
94 QUIC_srtp
95 QUIC_wechat-video
96 QUIC_dtls
97 QUIC_wireguard
98 TCP_dynamicPort
99 TCP_HTTP_dynamicPort
100 WebSocket_dynamicPort
101 mKCP_dynamicPort
102 mKCP_utp_dynamicPort
103 mKCP_srtp_dynamicPort
104 mKCP_wechat-video_dynamicPort
105 mKCP_dtls_dynamicPort
106 mKCP_wireguard_dynamicPort
107 QUIC_dynamicPort
108 QUIC_utp_dynamicPort
109 QUIC_srtp_dynamicPort
110 QUIC_wechat-video_dynamicPort
111 QUIC_dtls_dynamicPort
112 QUIC_wireguard_dynamicPort
113)
114
115ciphers=(
116 aes-128-cfb
117 aes-256-cfb
118 chacha20
119 chacha20-ietf
120 aes-128-gcm
121 aes-256-gcm
122 chacha20-ietf-poly1305
123)
124
125_load() {
126 local _dir="/etc/v2ray/233boy/v2ray/src/"
127 . "${_dir}$@"
128}
129_sys_timezone() {
130 IS_OPENVZ=
131 if hostnamectl status | grep -q openvz; then
132 IS_OPENVZ=1
133 fi
134
135 echo
136 timedatectl set-timezone Asia/Shanghai
137 timedatectl set-ntp true
138 echo "已将你的主机设置为Asia/Shanghai时区并通过systemd-timesyncd自动同步时间。"
139 echo
140
141 if [[ $IS_OPENVZ ]]; then
142 echo
143 echo -e "你的主机环境为 ${yellow}Openvz${none} ,建议使用${yellow}v2ray mkcp${none}系列协议。"
144 echo -e "注意:${yellow}Openvz${none} 系统时间无法由虚拟机内程序控制同步。"
145 echo -e "如果主机时间跟实际相差${yellow}超过90秒${none},v2ray将无法正常通信,请发ticket联系vps主机商调整。"
146 fi
147}
148
149_sys_time() {
150 echo -e "\n主机时间:${yellow}"
151 timedatectl status | sed -n '1p;4p'
152 echo -e "${none}"
153 [[ $IS_OPENV ]] && pause
154}
155v2ray_config() {
156 # clear
157 echo
158 while :; do
159 echo -e "请选择 "$yellow"V2Ray"$none" 传输协议 [${magenta}1-${#transport[*]}$none]"
160 echo
161 for ((i = 1; i <= ${#transport[*]}; i++)); do
162 Stream="${transport[$i - 1]}"
163 if [[ "$i" -le 9 ]]; then
164 # echo
165 echo -e "$yellow $i. $none${Stream}"
166 else
167 # echo
168 echo -e "$yellow $i. $none${Stream}"
169 fi
170 done
171 echo
172 echo "备注1: 含有 [dynamicPort] 的即启用动态端口.."
173 echo "备注2: [utp | srtp | wechat-video | dtls | wireguard] 分别伪装成 [BT下载 | 视频通话 | 微信视频通话 | DTLS 1.2 数据包 | WireGuard 数据包]"
174 echo
175 read -p "$(echo -e "(默认协议: ${cyan}TCP$none)"):" v2ray_transport
176 [ -z "$v2ray_transport" ] && v2ray_transport=1
177 case $v2ray_transport in
178 [1-9] | [1-2][0-9] | 3[0-2])
179 echo
180 echo
181 echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport - 1]}$none"
182 echo "----------------------------------------------------------------"
183 echo
184 break
185 ;;
186 *)
187 error
188 ;;
189 esac
190 done
191 v2ray_port_config
192}
193v2ray_port_config() {
194 case $v2ray_transport in
195 4 | 5)
196 tls_config
197 ;;
198 *)
199 local random=$(shuf -i20001-65535 -n1)
200 while :; do
201 echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]"
202 read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port
203 [ -z "$v2ray_port" ] && v2ray_port=$random
204 case $v2ray_port in
205 [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])
206 echo
207 echo
208 echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
209 echo "----------------------------------------------------------------"
210 echo
211 break
212 ;;
213 *)
214 error
215 ;;
216 esac
217 done
218 if [[ $v2ray_transport -ge 18 ]]; then
219 v2ray_dynamic_port_start
220 fi
221 ;;
222 esac
223}
224
225v2ray_dynamic_port_start() {
226
227 while :; do
228 echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]"
229 read -p "$(echo -e "(默认开始端口: ${cyan}10000$none):")" v2ray_dynamic_port_start_input
230 [ -z $v2ray_dynamic_port_start_input ] && v2ray_dynamic_port_start_input=10000
231 case $v2ray_dynamic_port_start_input in
232 $v2ray_port)
233 echo
234 echo " 不能和 V2Ray 端口一毛一样...."
235 echo
236 echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}"
237 error
238 ;;
239 [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])
240 echo
241 echo
242 echo -e "$yellow V2Ray 动态端口开始 = $cyan$v2ray_dynamic_port_start_input$none"
243 echo "----------------------------------------------------------------"
244 echo
245 break
246 ;;
247 *)
248 error
249 ;;
250 esac
251
252 done
253
254 if [[ $v2ray_dynamic_port_start_input -lt $v2ray_port ]]; then
255 lt_v2ray_port=true
256 fi
257
258 v2ray_dynamic_port_end
259}
260v2ray_dynamic_port_end() {
261
262 while :; do
263 echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]"
264 read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input
265 [ -z $v2ray_dynamic_port_end_input ] && v2ray_dynamic_port_end_input=20000
266 case $v2ray_dynamic_port_end_input in
267 [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])
268
269 if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then
270 echo
271 echo " 不能小于或等于 V2Ray 动态端口开始范围"
272 echo
273 echo -e " 当前 V2Ray 动态端口开始:${cyan}$v2ray_dynamic_port_start_input${none}"
274 error
275 elif [ $lt_v2ray_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $v2ray_port ]]; then
276 echo
277 echo " V2Ray 动态端口结束范围 不能包括 V2Ray 端口..."
278 echo
279 echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}"
280 error
281 else
282 echo
283 echo
284 echo -e "$yellow V2Ray 动态端口结束 = $cyan$v2ray_dynamic_port_end_input$none"
285 echo "----------------------------------------------------------------"
286 echo
287 break
288 fi
289 ;;
290 *)
291 error
292 ;;
293 esac
294
295 done
296
297}
298
299tls_config() {
300
301 echo
302 local random=$(shuf -i20001-65535 -n1)
303 while :; do
304 echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"],不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口"
305 read -p "$(echo -e "(默认端口: ${cyan}${random}$none):")" v2ray_port
306 [ -z "$v2ray_port" ] && v2ray_port=$random
307 case $v2ray_port in
308 80)
309 echo
310 echo " ...都说了不能选择 80 端口了咯....."
311 error
312 ;;
313 443)
314 echo
315 echo " ..都说了不能选择 443 端口了咯....."
316 error
317 ;;
318 [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])
319 echo
320 echo
321 echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
322 echo "----------------------------------------------------------------"
323 echo
324 break
325 ;;
326 *)
327 error
328 ;;
329 esac
330 done
331
332 while :; do
333 echo
334 echo -e "请输入一个 $magenta正确的域名$none,一定一定一定要正确,不!能!出!错!"
335 read -p "(例如:233blog.com): " domain
336 [ -z "$domain" ] && error && continue
337 echo
338 echo
339 echo -e "$yellow 你的域名 = $cyan$domain$none"
340 echo "----------------------------------------------------------------"
341 break
342 done
343 get_ip
344 echo
345 echo
346 echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none"
347 echo
348 echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none"
349 echo
350 echo -e "$yellow 请将 $magenta$domain$none $yellow解析到: $cyan$ip$none"
351 echo "----------------------------------------------------------------"
352 echo
353
354 while :; do
355
356 read -p "$(echo -e "(是否已经正确解析: [${magenta}Y$none]):") " record
357 if [[ -z "$record" ]]; then
358 error
359 else
360 if [[ "$record" == [Yy] ]]; then
361 domain_check
362 echo
363 echo
364 echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none"
365 echo "----------------------------------------------------------------"
366 echo
367 break
368 else
369 error
370 fi
371 fi
372
373 done
374
375 if [[ $v2ray_transport -ne 5 ]]; then
376 auto_tls_config
377 else
378 caddy=true
379 install_caddy_info="打开"
380 fi
381
382 if [[ $caddy ]]; then
383 path_config_ask
384 fi
385}
386auto_tls_config() {
387 echo -e "
388
389 安装 Caddy 来实现 自动配置 TLS
390
391 如果你已经安装 Nginx 或 Caddy
392
393 $yellow并且..自己能搞定配置 TLS$none
394
395 那么就不需要 打开自动配置 TLS
396 "
397 echo "----------------------------------------------------------------"
398 echo
399
400 while :; do
401
402 read -p "$(echo -e "(是否自动配置 TLS: [${magenta}Y/N$none]):") " auto_install_caddy
403 if [[ -z "$auto_install_caddy" ]]; then
404 error
405 else
406 if [[ "$auto_install_caddy" == [Yy] ]]; then
407 caddy=true
408 install_caddy_info="打开"
409 echo
410 echo
411 echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none"
412 echo "----------------------------------------------------------------"
413 echo
414 break
415 elif [[ "$auto_install_caddy" == [Nn] ]]; then
416 install_caddy_info="关闭"
417 echo
418 echo
419 echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none"
420 echo "----------------------------------------------------------------"
421 echo
422 break
423 else
424 error
425 fi
426 fi
427
428 done
429}
430path_config_ask() {
431 echo
432 while :; do
433 echo -e "是否开启 网站伪装 和 路径分流 [${magenta}Y/N$none]"
434 read -p "$(echo -e "(默认: [${cyan}N$none]):")" path_ask
435 [[ -z $path_ask ]] && path_ask="n"
436
437 case $path_ask in
438 Y | y)
439 path_config
440 break
441 ;;
442 N | n)
443 echo
444 echo
445 echo -e "$yellow 网站伪装 和 路径分流 = $cyan不想配置$none"
446 echo "----------------------------------------------------------------"
447 echo
448 break
449 ;;
450 *)
451 error
452 ;;
453 esac
454 done
455}
456path_config() {
457 echo
458 while :; do
459 echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可"
460 read -p "$(echo -e "(默认: [${cyan}233blog$none]):")" path
461 [[ -z $path ]] && path="233blog"
462
463 case $path in
464 *[/$]*)
465 echo
466 echo -e " 由于这个脚本太辣鸡了..所以分流的路径不能包含$red / $none或$red $ $none这两个符号.... "
467 echo
468 error
469 ;;
470 *)
471 echo
472 echo
473 echo -e "$yellow 分流的路径 = ${cyan}/${path}$none"
474 echo "----------------------------------------------------------------"
475 echo
476 break
477 ;;
478 esac
479 done
480 is_path=true
481 proxy_site_config
482}
483proxy_site_config() {
484 echo
485 while :; do
486 echo -e "请输入 ${magenta}一个正确的$none ${cyan}网址$none 用来作为 ${cyan}网站的伪装$none , 例如 https://liyafly.com"
487 echo -e "举例...你当前的域名是 $green$domain$none , 伪装的网址的是 https://liyafly.com"
488 echo -e "然后打开你的域名时候...显示出来的内容就是来自 https://liyafly.com 的内容"
489 echo -e "其实就是一个反代...明白就好..."
490 echo -e "如果不能伪装成功...可以使用 v2ray config 修改伪装的网址"
491 read -p "$(echo -e "(默认: [${cyan}https://liyafly.com$none]):")" proxy_site
492 [[ -z $proxy_site ]] && proxy_site="https://liyafly.com"
493
494 case $proxy_site in
495 *[#$]*)
496 echo
497 echo -e " 由于这个脚本太辣鸡了..所以伪装的网址不能包含$red # $none或$red $ $none这两个符号.... "
498 echo
499 error
500 ;;
501 *)
502 echo
503 echo
504 echo -e "$yellow 伪装的网址 = ${cyan}${proxy_site}$none"
505 echo "----------------------------------------------------------------"
506 echo
507 break
508 ;;
509 esac
510 done
511}
512
513blocked_hosts() {
514 echo
515 while :; do
516 echo -e "是否开启广告拦截(会影响性能) [${magenta}Y/N$none]"
517 read -p "$(echo -e "(默认 [${cyan}N$none]):")" blocked_ad
518 [[ -z $blocked_ad ]] && blocked_ad="n"
519
520 case $blocked_ad in
521 Y | y)
522 blocked_ad_info="开启"
523 ban_ad=true
524 echo
525 echo
526 echo -e "$yellow 广告拦截 = $cyan开启$none"
527 echo "----------------------------------------------------------------"
528 echo
529 break
530 ;;
531 N | n)
532 blocked_ad_info="关闭"
533 echo
534 echo
535 echo -e "$yellow 广告拦截 = $cyan关闭$none"
536 echo "----------------------------------------------------------------"
537 echo
538 break
539 ;;
540 *)
541 error
542 ;;
543 esac
544 done
545}
546shadowsocks_config() {
547
548 echo
549
550 while :; do
551 echo -e "是否配置 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]"
552 read -p "$(echo -e "(默认 [${cyan}N$none]):") " install_shadowsocks
553 [[ -z "$install_shadowsocks" ]] && install_shadowsocks="n"
554 if [[ "$install_shadowsocks" == [Yy] ]]; then
555 echo
556 shadowsocks=true
557 shadowsocks_port_config
558 break
559 elif [[ "$install_shadowsocks" == [Nn] ]]; then
560 break
561 else
562 error
563 fi
564
565 done
566
567}
568
569shadowsocks_port_config() {
570 local random=$(shuf -i20001-65535 -n1)
571 while :; do
572 echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2Ray"$none" 端口相同"
573 read -p "$(echo -e "(默认端口: ${cyan}${random}$none):") " ssport
574 [ -z "$ssport" ] && ssport=$random
575 case $ssport in
576 $v2ray_port)
577 echo
578 echo " 不能和 V2Ray 端口一毛一样...."
579 error
580 ;;
581 [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])
582 if [[ $v2ray_transport == [45] ]]; then
583 local tls=ture
584 fi
585 if [[ $tls && $ssport == "80" ]] || [[ $tls && $ssport == "443" ]]; then
586 echo
587 echo -e "由于你已选择了 "$green"WebSocket + TLS $none或$green HTTP/2"$none" 传输协议."
588 echo
589 echo -e "所以不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口"
590 error
591 elif [[ $v2ray_dynamic_port_start_input == $ssport || $v2ray_dynamic_port_end_input == $ssport ]]; then
592 local multi_port="${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}"
593 echo
594 echo " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:$multi_port"
595 error
596 elif [[ $v2ray_dynamic_port_start_input -lt $ssport && $ssport -le $v2ray_dynamic_port_end_input ]]; then
597 local multi_port="${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}"
598 echo
599 echo " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:$multi_port"
600 error
601 else
602 echo
603 echo
604 echo -e "$yellow Shadowsocks 端口 = $cyan$ssport$none"
605 echo "----------------------------------------------------------------"
606 echo
607 break
608 fi
609 ;;
610 *)
611 error
612 ;;
613 esac
614
615 done
616
617 shadowsocks_password_config
618}
619shadowsocks_password_config() {
620
621 while :; do
622 echo -e "请输入 "$yellow"Shadowsocks"$none" 密码"
623 read -p "$(echo -e "(默认密码: ${cyan}233blog.com$none)"): " sspass
624 [ -z "$sspass" ] && sspass="233blog.com"
625 case $sspass in
626 *[/$]*)
627 echo
628 echo -e " 由于这个脚本太辣鸡了..所以密码不能包含$red / $none或$red $ $none这两个符号.... "
629 echo
630 error
631 ;;
632 *)
633 echo
634 echo
635 echo -e "$yellow Shadowsocks 密码 = $cyan$sspass$none"
636 echo "----------------------------------------------------------------"
637 echo
638 break
639 ;;
640 esac
641
642 done
643
644 shadowsocks_ciphers_config
645}
646shadowsocks_ciphers_config() {
647
648 while :; do
649 echo -e "请选择 "$yellow"Shadowsocks"$none" 加密协议 [${magenta}1-${#ciphers[*]}$none]"
650 for ((i = 1; i <= ${#ciphers[*]}; i++)); do
651 ciphers_show="${ciphers[$i - 1]}"
652 echo
653 echo -e "$yellow $i. $none${ciphers_show}"
654 done
655 echo
656 read -p "$(echo -e "(默认加密协议: ${cyan}${ciphers[6]}$none)"):" ssciphers_opt
657 [ -z "$ssciphers_opt" ] && ssciphers_opt=7
658 case $ssciphers_opt in
659 [1-7])
660 ssciphers=${ciphers[$ssciphers_opt - 1]}
661 echo
662 echo
663 echo -e "$yellow Shadowsocks 加密协议 = $cyan${ssciphers}$none"
664 echo "----------------------------------------------------------------"
665 echo
666 break
667 ;;
668 *)
669 error
670 ;;
671 esac
672
673 done
674 pause
675}
676
677install_info() {
678 clear
679 echo
680 echo " ....准备安装了咯..看看有毛有配置正确了..."
681 echo
682 echo "---------- 安装信息 -------------"
683 echo
684 echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport - 1]}$none"
685
686 if [[ $v2ray_transport == [45] ]]; then
687 echo
688 echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
689 echo
690 echo -e "$yellow 你的域名 = $cyan$domain$none"
691 echo
692 echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none"
693 echo
694 echo -e "$yellow 自动配置 TLS = $cyan$install_caddy_info$none"
695
696 if [[ $ban_ad ]]; then
697 echo
698 echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none"
699 fi
700 if [[ $is_path ]]; then
701 echo
702 echo -e "$yellow 路径分流 = ${cyan}/${path}$none"
703 fi
704 elif [[ $v2ray_transport -ge 18 ]]; then
705 echo
706 echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
707 echo
708 echo -e "$yellow V2Ray 动态端口范围 = $cyan${v2ray_dynamic_port_start_input} - ${v2ray_dynamic_port_end_input}$none"
709
710 if [[ $ban_ad ]]; then
711 echo
712 echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none"
713 fi
714 else
715 echo
716 echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none"
717
718 if [[ $ban_ad ]]; then
719 echo
720 echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none"
721 fi
722 fi
723 if [ $shadowsocks ]; then
724 echo
725 echo -e "$yellow Shadowsocks 端口 = $cyan$ssport$none"
726 echo
727 echo -e "$yellow Shadowsocks 密码 = $cyan$sspass$none"
728 echo
729 echo -e "$yellow Shadowsocks 加密协议 = $cyan${ssciphers}$none"
730 else
731 echo
732 echo -e "$yellow 是否配置 Shadowsocks = ${cyan}未配置${none}"
733 fi
734 echo
735 echo "---------- END -------------"
736 echo
737 pause
738 echo
739}
740
741domain_check() {
742 # if [[ $cmd == "yum" ]]; then
743 # yum install bind-utils -y
744 # else
745 # $cmd install dnsutils -y
746 # fi
747 # test_domain=$(dig $domain +short)
748 test_domain=$(ping $domain -c 1 | grep -oE -m1 "([0-9]{1,3}\.){3}[0-9]{1,3}")
749 if [[ $test_domain != $ip ]]; then
750 echo
751 echo -e "$red 检测域名解析错误....$none"
752 echo
753 echo -e " 你的域名: $yellow$domain$none 未解析到: $cyan$ip$none"
754 echo
755 echo -e " 你的域名当前解析到: $cyan$test_domain$none"
756 echo
757 echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 Status 那里点一下那图标..让它变灰"
758 echo
759 exit 1
760 fi
761}
762
763install_caddy() {
764 # download caddy file then install
765 _load download-caddy.sh
766 _download_caddy_file
767 _install_caddy_service
768 caddy_config
769
770}
771caddy_config() {
772 # local email=$(shuf -i1-10000000000 -n1)
773 _load caddy-config.sh
774
775 # systemctl restart caddy
776 do_service restart caddy
777}
778
779install_v2ray() {
780 $cmd update -y
781 if [[ $cmd == "apt-get" ]]; then
782 $cmd install -y lrzsz git zip unzip curl wget qrencode libcap2-bin dbus
783 else
784 # $cmd install -y lrzsz git zip unzip curl wget qrencode libcap iptables-services
785 $cmd install -y lrzsz git zip unzip curl wget qrencode libcap
786 fi
787 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
788 [ -d /etc/v2ray ] && rm -rf /etc/v2ray
789 # date -s "$(curl -sI g.cn | grep Date | cut -d' ' -f3-6)Z"
790 _sys_timezone
791 _sys_time
792
793 if [[ $local_install ]]; then
794 if [[ ! -d $(pwd)/config ]]; then
795 echo
796 echo -e "$red 哎呀呀...安装失败了咯...$none"
797 echo
798 echo -e " 请确保你有完整的上传 233v2.com 的 V2Ray 一键安装脚本 & 管理脚本到当前 ${green}$(pwd) $none目录下"
799 echo
800 exit 1
801 fi
802 mkdir -p /etc/v2ray/233boy/v2ray
803 cp -rf $(pwd)/* /etc/v2ray/233boy/v2ray
804 else
805 pushd /tmp
806 git clone https://github.com/233boy/v2ray -b "$_gitbranch" /etc/v2ray/233boy/v2ray --depth=1
807 popd
808
809 fi
810
811 if [[ ! -d /etc/v2ray/233boy/v2ray ]]; then
812 echo
813 echo -e "$red 哎呀呀...克隆脚本仓库出错了...$none"
814 echo
815 echo -e " 温馨提示..... 请尝试自行安装 Git: ${green}$cmd install -y git $none 之后再安装此脚本"
816 echo
817 exit 1
818 fi
819
820 # download v2ray file then install
821 _load download-v2ray.sh
822 _download_v2ray_file
823 _install_v2ray_service
824 _mkdir_dir
825}
826
827open_port() {
828 if [[ $cmd == "apt-get" ]]; then
829 if [[ $1 != "multiport" ]]; then
830
831 iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
832 iptables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT
833 ip6tables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
834 ip6tables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT
835
836 # firewall-cmd --permanent --zone=public --add-port=$1/tcp
837 # firewall-cmd --permanent --zone=public --add-port=$1/udp
838 # firewall-cmd --reload
839
840 else
841
842 local multiport="${v2ray_dynamic_port_start_input}:${v2ray_dynamic_port_end_input}"
843 iptables -I INPUT -p tcp --match multiport --dports $multiport -j ACCEPT
844 iptables -I INPUT -p udp --match multiport --dports $multiport -j ACCEPT
845 ip6tables -I INPUT -p tcp --match multiport --dports $multiport -j ACCEPT
846 ip6tables -I INPUT -p udp --match multiport --dports $multiport -j ACCEPT
847
848 # local multi_port="${v2ray_dynamic_port_start_input}-${v2ray_dynamic_port_end_input}"
849 # firewall-cmd --permanent --zone=public --add-port=$multi_port/tcp
850 # firewall-cmd --permanent --zone=public --add-port=$multi_port/udp
851 # firewall-cmd --reload
852
853 fi
854 iptables-save >/etc/iptables.rules.v4
855 ip6tables-save >/etc/iptables.rules.v6
856 # else
857 # service iptables save >/dev/null 2>&1
858 # service ip6tables save >/dev/null 2>&1
859 fi
860}
861del_port() {
862 if [[ $cmd == "apt-get" ]]; then
863 if [[ $1 != "multiport" ]]; then
864 # if [[ $cmd == "apt-get" ]]; then
865 iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
866 iptables -D INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT
867 ip6tables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
868 ip6tables -D INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT
869 # else
870 # firewall-cmd --permanent --zone=public --remove-port=$1/tcp
871 # firewall-cmd --permanent --zone=public --remove-port=$1/udp
872 # fi
873 else
874 # if [[ $cmd == "apt-get" ]]; then
875 local ports="${v2ray_dynamicPort_start}:${v2ray_dynamicPort_end}"
876 iptables -D INPUT -p tcp --match multiport --dports $ports -j ACCEPT
877 iptables -D INPUT -p udp --match multiport --dports $ports -j ACCEPT
878 ip6tables -D INPUT -p tcp --match multiport --dports $ports -j ACCEPT
879 ip6tables -D INPUT -p udp --match multiport --dports $ports -j ACCEPT
880 # else
881 # local ports="${v2ray_dynamicPort_start}-${v2ray_dynamicPort_end}"
882 # firewall-cmd --permanent --zone=public --remove-port=$ports/tcp
883 # firewall-cmd --permanent --zone=public --remove-port=$ports/udp
884 # fi
885 fi
886 iptables-save >/etc/iptables.rules.v4
887 ip6tables-save >/etc/iptables.rules.v6
888 # else
889 # service iptables save >/dev/null 2>&1
890 # service ip6tables save >/dev/null 2>&1
891 fi
892
893}
894
895config() {
896 cp -f /etc/v2ray/233boy/v2ray/config/backup.conf $backup
897 cp -f /etc/v2ray/233boy/v2ray/v2ray.sh $_v2ray_sh
898 chmod +x $_v2ray_sh
899
900 v2ray_id=$uuid
901 alterId=233
902 ban_bt=true
903 if [[ $v2ray_transport -ge 18 ]]; then
904 v2ray_dynamicPort_start=${v2ray_dynamic_port_start_input}
905 v2ray_dynamicPort_end=${v2ray_dynamic_port_end_input}
906 fi
907 _load config.sh
908
909 if [[ $cmd == "apt-get" ]]; then
910 cat >/etc/network/if-pre-up.d/iptables <<-EOF
911 #!/bin/sh
912 /sbin/iptables-restore < /etc/iptables.rules.v4
913 /sbin/ip6tables-restore < /etc/iptables.rules.v6
914 EOF
915 chmod +x /etc/network/if-pre-up.d/iptables
916 # else
917 # [ $(pgrep "firewall") ] && systemctl stop firewalld
918 # systemctl mask firewalld
919 # systemctl disable firewalld
920 # systemctl enable iptables
921 # systemctl enable ip6tables
922 # systemctl start iptables
923 # systemctl start ip6tables
924 fi
925
926 [[ $shadowsocks ]] && open_port $ssport
927 if [[ $v2ray_transport == [45] ]]; then
928 open_port "80"
929 open_port "443"
930 open_port $v2ray_port
931 elif [[ $v2ray_transport -ge 18 ]]; then
932 open_port $v2ray_port
933 open_port "multiport"
934 else
935 open_port $v2ray_port
936 fi
937 # systemctl restart v2ray
938 do_service restart v2ray
939 backup_config
940
941}
942
943backup_config() {
944 sed -i "18s/=1/=$v2ray_transport/; 21s/=2333/=$v2ray_port/; 24s/=$old_id/=$uuid/" $backup
945 if [[ $v2ray_transport -ge 18 ]]; then
946 sed -i "30s/=10000/=$v2ray_dynamic_port_start_input/; 33s/=20000/=$v2ray_dynamic_port_end_input/" $backup
947 fi
948 if [[ $shadowsocks ]]; then
949 sed -i "42s/=/=true/; 45s/=6666/=$ssport/; 48s/=233blog.com/=$sspass/; 51s/=chacha20-ietf/=$ssciphers/" $backup
950 fi
951 [[ $v2ray_transport == [45] ]] && sed -i "36s/=233blog.com/=$domain/" $backup
952 [[ $caddy ]] && sed -i "39s/=/=true/" $backup
953 [[ $ban_ad ]] && sed -i "54s/=/=true/" $backup
954 if [[ $is_path ]]; then
955 sed -i "57s/=/=true/; 60s/=233blog/=$path/" $backup
956 sed -i "63s#=https://liyafly.com#=$proxy_site#" $backup
957 fi
958}
959
960get_ip() {
961 ip=$(curl -s https://ipinfo.io/ip)
962 [[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip)
963 [[ -z $ip ]] && ip=$(curl -s https://api.ipify.org)
964 [[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org)
965 [[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/ip)
966 [[ -z $ip ]] && ip=$(curl -s https://api.myip.com | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}")
967 [[ -z $ip ]] && ip=$(curl -s icanhazip.com)
968 [[ -z $ip ]] && ip=$(curl -s myip.ipip.net | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}")
969 [[ -z $ip ]] && echo -e "\n$red 这垃圾小鸡扔了吧!$none\n" && exit
970}
971
972error() {
973
974 echo -e "\n$red 输入错误!$none\n"
975
976}
977
978pause() {
979
980 read -rsp "$(echo -e "按$green Enter 回车键 $none继续....或按$red Ctrl + C $none取消.")" -d $'\n'
981 echo
982}
983do_service() {
984 if [[ $systemd ]]; then
985 systemctl $1 $2
986 else
987 service $2 $1
988 fi
989}
990show_config_info() {
991 clear
992 _load v2ray-info.sh
993 _v2_args
994 _v2_info
995 _load ss-info.sh
996
997}
998
999install() {
1000 if [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f $backup && -d /etc/v2ray/233boy/v2ray ]]; then
1001 echo
1002 echo " 大佬...你已经安装 V2Ray 啦...无需重新安装"
1003 echo
1004 echo -e " $yellow输入 ${cyan}v2ray${none} $yellow即可管理 V2Ray${none}"
1005 echo
1006 exit 1
1007 elif [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f /etc/v2ray/233blog_v2ray_backup.txt && -d /etc/v2ray/233boy/v2ray ]]; then
1008 echo
1009 echo " 如果你需要继续安装.. 请先卸载旧版本"
1010 echo
1011 echo -e " $yellow输入 ${cyan}v2ray uninstall${none} $yellow即可卸载${none}"
1012 echo
1013 exit 1
1014 fi
1015 v2ray_config
1016 blocked_hosts
1017 shadowsocks_config
1018 install_info
1019 # [[ $caddy ]] && domain_check
1020 install_v2ray
1021 if [[ $caddy || $v2ray_port == "80" ]]; then
1022 if [[ $cmd == "yum" ]]; then
1023 [[ $(pgrep "httpd") ]] && systemctl stop httpd
1024 [[ $(command -v httpd) ]] && yum remove httpd -y
1025 else
1026 [[ $(pgrep "apache2") ]] && service apache2 stop
1027 [[ $(command -v apache2) ]] && apt-get remove apache2* -y
1028 fi
1029 fi
1030 [[ $caddy ]] && install_caddy
1031
1032 ## bbr
1033 _load bbr.sh
1034 _try_enable_bbr
1035
1036 get_ip
1037 config
1038 show_config_info
1039}
1040uninstall() {
1041
1042 if [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f $backup && -d /etc/v2ray/233boy/v2ray ]]; then
1043 . $backup
1044 if [[ $mark ]]; then
1045 _load uninstall.sh
1046 else
1047 echo
1048 echo -e " $yellow输入 ${cyan}v2ray uninstall${none} $yellow即可卸载${none}"
1049 echo
1050 fi
1051
1052 elif [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f /etc/v2ray/233blog_v2ray_backup.txt && -d /etc/v2ray/233boy/v2ray ]]; then
1053 echo
1054 echo -e " $yellow输入 ${cyan}v2ray uninstall${none} $yellow即可卸载${none}"
1055 echo
1056 else
1057 echo -e "
1058 $red 大胸弟...你貌似毛有安装 V2Ray ....卸载个鸡鸡哦...$none
1059
1060 备注...仅支持卸载使用我 (233v2.com) 提供的 V2Ray 一键安装脚本
1061 " && exit 1
1062 fi
1063
1064}
1065
1066args=$1
1067_gitbranch=$2
1068[ -z $1 ] && args="online"
1069case $args in
1070online)
1071 #hello world
1072 [[ -z $_gitbranch ]] && _gitbranch="master"
1073 ;;
1074local)
1075 local_install=true
1076 ;;
1077*)
1078 echo
1079 echo -e " 你输入的这个参数 <$red $args $none> ...这个是什么鬼啊...脚本不认识它哇"
1080 echo
1081 echo -e " 这个辣鸡脚本仅支持输入$green local / online $none参数"
1082 echo
1083 echo -e " 输入$yellow local $none即是使用本地安装"
1084 echo
1085 echo -e " 输入$yellow online $none即是使用在线安装 (默认)"
1086 echo
1087 exit 1
1088 ;;
1089esac
1090
1091clear
1092while :; do
1093 echo
1094 echo "........... V2Ray 一键安装脚本 & 管理脚本 by 233v2.com .........."
1095 echo
1096 echo "帮助说明: https://233v2.com/post/1/"
1097 echo
1098 echo "搭建教程: https://233v2.com/post/2/"
1099 echo
1100 echo " 1. 安装"
1101 echo
1102 echo " 2. 卸载"
1103 echo
1104 if [[ $local_install ]]; then
1105 echo -e "$yellow 温馨提示.. 本地安装已启用 ..$none"
1106 echo
1107 fi
1108 read -p "$(echo -e "请选择 [${magenta}1-2$none]:")" choose
1109 case $choose in
1110 1)
1111 install
1112 break
1113 ;;
1114 2)
1115 uninstall
1116 break
1117 ;;
1118 *)
1119 error
1120 ;;
1121 esac
1122done
1123