-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
ssr_old.sh
1854 lines (1834 loc) · 82.2 KB
/
ssr_old.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================
# System Required: CentOS 6/Debian/Ubuntu 14.04+
# Description: Install the ShadowsocksR server
# Version: 1.2.9
# Author: Toyo
# Blog: https://doub.io/ss-jc42/
#=================================================
#ssr_pid="/var/run/shadowsocks.pid"
ssr_file="/etc/shadowsocksr"
ssr_ss_file="/etc/shadowsocksr/shadowsocks"
config_file="/etc/shadowsocksr/config.json"
config_user_file="/etc/shadowsocksr/user-config.json"
Libsodiumr_file="/root/libsodium"
Libsodiumr_ver="1.0.11"
auto_restart_cron="auto_restart_cron.sh"
Green_font_prefix="\033[32m"
Red_font_prefix="\033[31m"
Green_background_prefix="\033[42;37m"
Red_background_prefix="\033[41;37m"
Font_color_suffix="\033[0m"
Separator_1="——————————————————————————————"
# 脚本文字变量(Translation)
Language(){
if [[ ! -e "${PWD}/lang_en" ]]; then
Word_default="默认"
Word_unlimited="无限"
Word_user="用户"
Word_port="端口"
Word_pass="密码"
Word_method="加密"
Word_protocol="协议"
Word_obfs="混淆"
Word_ss_like=" SS 链接"
Word_ss_qr_code=" SS 二维码"
Word_ssr_like=" SSR 链接"
Word_ssr_qr_code=" SSR 二维码"
Word_single_port="单端口"
Word_multi_port="多端口"
Word_current_mode="当前模式"
Word_current_status="当前状态"
Word_number_of_devices="设备数"
Word_number_of_devices_limit="设备数限制"
Word_single_threaded_speed_limit="单线程限速"
Word_port_total_speed_limit="端口总限速"
Word_the_installation_is_complete="安装完成"
Word_installation_failed="安装失败"
Word_uninstall_is_complete="卸载完成"
Word_uninstall_cancelled="卸载已取消..."
Word_canceled="已取消..."
Word_cancel="取消"
Word_startup_failed="启动失败"
Word_stop_failing="停止失败"
Word_stopped="已停止"
Word_installed="已安装"
Word_not_installed="未安装"
Word_has_started="已启动"
Word_have_not_started="未启动"
Word_running="正在运行"
Word_not_running="没有运行"
Word_info="信息"
Word_error="错误"
Word_Prompt="提示"
Word_timing_interval="定时间隔"
Word_and="并"
Word_but="但"
Word_serverspeeder="锐速"
Info_switch_single_port_mode="你确定要切换模式为 ${Word_single_port} ?[y/N]"
Info_switch_multi_port_mode="你确定要切换模式为 ${Word_multi_port} ?[y/N]"
Info_input_port="请输入ShadowsocksR ${Word_port} [1-65535]"
Info_input_pass="请输入ShadowsocksR ${Word_pass}"
Info_input_method="请输入数字 来选择ShadowsocksR ${Word_method}"
Info_input_protocol="请输入数字 来选择ShadowsocksR ${Word_protocol}( auth_aes128_* 以后的协议不再支持 兼容原版 )"
Info_input_number_of_devices="请输入 ShadowsocksR账号欲限制的设备数 (${Green_font_prefix} auth_* 系列协议 不兼容原版才有效 ${Font_color_suffix})"
Prompt_number_of_devices="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}该设备数限制,指的是每个端口同一时间能链接的客户端数量(多端口模式,每个端口都是独立计算)。"
Info_input_obfs="请输入数字 来选择ShadowsocksR ${Word_obfs}"
Info_protocol_compatible="是否设置 协议 兼容原版 ( _compatible )? [Y/n] :"
Info_obfs_compatible="是否设置 混淆 兼容原版 ( _compatible )? [Y/n] :"
Info_protocol_obfs_compatible="是否设置 协议/混淆 兼容原版 ( _compatible )? [Y/n] :"
Info_input_single_threaded_speed_limit="请输入 你要设置的每个端口 单线程 限速上限(单位:KB/S)"
Prompt_input_single_threaded_speed_limit="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}这个指的是,每个端口 单线程的限速上限,多线程即无效。"
Info_total_port_speed_limit="请输入 你要设置的每个端口 总速度 限速上限(单位:KB/S)"
Prompt_total_port_speed_limit="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}这个指的是,每个端口 总速度 限速上限,单个端口整体限速。"
Info_input_modify_the_type="请输入数字 来选择你要修改的类型 :
1. 修改 ${Word_port}/${Word_pass}
2. 修改 ${Word_method}/${Word_protocol}/${Word_obfs}"
info_input_select_user_id_modified="请选择并输入 你要修改的用户前面的数字 :"
Info_input_select_user_id_del="请选择并输入 你要删除的用户前面的数字 :"
Prompt_method_protocol_obfs_modified="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} ShadowsocksR ${Word_method}/${Word_protocol}/${Word_obfs}已修改!"
Info_jq_installation_is_complete="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} JSON解析器 JQ 安装完成,继续..."
Info_jq_is_installed="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} 检测到 JSON解析器 JQ 已安装,继续..."
Info_uninstall_ssr="确定要卸载 ShadowsocksR ? [y/N]"
Info_uninstall_server_speeder="确定要卸载 ${Word_serverspeeder} ? [y/N]"
Info_install_bbr="确定要安装 BBR ? [y/n]"
Info_install_bbr_0="${Green_font_prefix} [安装前 请注意] ${Font_color_suffix}
1. 安装开启BBR,需要更换内核,存在更换失败等风险(重启后无法开机)
2. 本脚本仅支持 Debian / Ubuntu 系统更换内核,OpenVZ虚拟化 不支持更换内核 !
3. Debian 更换内核过程中会提示 [ 是否终止卸载内核 ] ,请选择 ${Green_font_prefix} NO ${Font_color_suffix}
4. 安装BBR并重启后,需要重新运行脚本开启BBR ${Green_font_prefix} bash bbr.sh start ${Font_color_suffix}"
Info_input_set_crontab_interval="请输入ShadowsocksR 定时重启的间隔"
Info_input_set_crontab_interval_default="每天凌晨2点0分 [0 2 * * *]"
Info_set_crontab_interval_0="${Green_font_prefix} 格式说明 : ${Font_color_suffix}
格式: ${Green_font_prefix} * * * * * ${Font_color_suffix},分别对应 ${Green_font_prefix} 分钟 小时 日 月 星期 ${Font_color_suffix}
示例: ${Green_font_prefix} 30 2 * * * ${Font_color_suffix},每天 凌晨2点30分时 重启一次
示例: ${Green_font_prefix} 30 2 */3 * * ${Font_color_suffix},每隔3天 凌晨2点30分时 重启一次
示例: ${Green_font_prefix} 30 */2 * * * ${Font_color_suffix},每天 每隔两小时 在30分时 重启一次"
Info_no_cron_installed="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} 检测到没有安装 corn ,开始安装..."
Info_input_set_cron="请输入数字 来选择你要做什么
1. 添加 定时任务
2. 删除 定时任务
${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}暂时只能添加设置一个定时重启任务。"
Info_set_corn_status="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} corn 当前没有定时重启任务 !"
Info_set_corn_del_success="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} corn 删除定时重启任务成功 !"
Info_set_corn_add_success="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} ShadowsocksR 定时重启任务添加成功 !"
Info_limit_the_number_of_devices="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} ShadowsocksR 设备数限制 已修改 !"
Info_port_speed_limit="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} ShadowsocksR 端口限速 已修改 !"
Info_switch_language_english="Are you sure you want to switch the script language to English ? [y/n]"
Info_switch_language_chinese="确定要切换脚本语言为 中文 ? [y/n]"
Info_switch_language_1="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} Re-run the script to see the language after switching !"
Errpr_input_num_error="${Red_font_prefix}[${Word_error}]${Font_color_suffix} 请输入正确的数字 !"
Error_not_install_ssr="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} 没有发现安装ShadowsocksR,请检查 !"
Error_ssr_installed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR已安装 !"
Error_no_multi_port_users_were_found="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} 没有发现 多端口用户,请检查 !"
Error_jq_installation_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} JSON解析器 JQ 安装失败 !"
Error_does_not_support_the_system="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} 本脚本不支持当前系统 !"
Error_ssr_download_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR 下载失败 !"
Error_ssr_failed_to_start="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR 启动失败 !"
Error_the_current_mode_is_single_port="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} 当前模式为 单端口,请检查 !"
Error_the_current_mode_is_multi_port="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} 当前模式为 多端口,请检查 !"
Error_multi_port_user_remaining_one="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} 当前多端口用户 仅剩一个,无法删除 !"
Error_startup_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR 启动失败, 请检查日志 !"
Error_no_log_found="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} 没有找到日志文件,请检查 !"
Error_server_speeder_installed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ${Word_serverspeeder} 已安装 !"
Error_server_speeder_installation_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ${Word_serverspeeder} 安装失败 !"
Error_server_speeder_not_installed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ${Word_serverspeeder} 没有安装,请检查 !"
Error_cron_installation_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} corn 安装失败 !"
Error_set_corn_del_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} corn 删除定时重启任务失败 !"
Error_set_corn_add_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR 定时重启任务添加失败 !"
Error_set_corn_Write_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR 定时重启脚本写入失败 !"
Error_limit_the_number_of_devices_1="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR当前协议为 兼容原版(_compatible),限制设备数无效 !"
Error_limit_the_number_of_devices_2="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR当前协议为 原版(origin),限制设备数无效 !"
Prompt_method_libsodium="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}chacha20*等加密方式 需要安装 libsodium 支持库,否则会启动失败 !"
Prompt_any_key="请按任意键继续,如有配置错误请使用 Ctrl+C 退出。"
Prompt_check_if_the_configuration_is_incorrect="请检查Shadowsocks账号配置是否有误 !"
Prompt_your_account_configuration="你的ShadowsocksR 账号配置 :"
Prompt_ssr_status_on="ShadowsocksR 正在运行 !"
Prompt_ssr_status_off="ShadowsocksR 没有运行 !"
Prompt_tip="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}
浏览器中,打开二维码链接,就可以看到二维码图片。
协议和混淆后面的[ _compatible ],指的是兼容原版Shadowsocks协议/混淆。"
Prompt_total_number_of_users="当前用户配置总数为:"
Prompt_total_number_of_ip="当前链接的IP总数为:"
Prompt_the_currently_connected_ip="当前连接的IP:"
Prompt_total_number_of_ip_number="IP数量:"
Prompt_modify_multi_port_user="多端口用户已修改 !"
Prompt_add_multi_port_user="多端口用户已添加 !"
Prompt_del_multi_port_user="多端口用户已删除 !"
Prompt_log="使用 ${Red_font_prefix} Ctrl+C ${Font_color_suffix} 键退出查看日志 !"
Prompt_switch_language_chinese=" The current scripting language: English"
Prompt_switch_language_english=" 当前脚本语言为: 中文"
#菜单
Menu_prompt_1="请输入一个数字来选择对应的选项"
Menu_prompt_2="(请输入数字 0-27): "
Menu_prompt_3="请选择并输入数字 0-27"
Menu_options="${Green_font_prefix} 1. ${Font_color_suffix}安装 ShadowsocksR
${Green_font_prefix} 2. ${Font_color_suffix}安装 libsodium(chacha20)
${Green_font_prefix} 3. ${Font_color_suffix}显示 单/多端口 账号信息
${Green_font_prefix} 4. ${Font_color_suffix}显示 单/多端口 连接信息
${Green_font_prefix} 5. ${Font_color_suffix}修改 单端口用户配置
${Green_font_prefix} 6. ${Font_color_suffix}手动 修改 用户配置
${Green_font_prefix} 7. ${Font_color_suffix}卸载 ShadowsocksR
${Green_font_prefix} 8. ${Font_color_suffix}更新 ShadowsocksR
——————————————————
${Green_font_prefix} 9. ${Font_color_suffix}切换 单/多端口 模式
${Green_font_prefix} 10. ${Font_color_suffix}添加 多端口用户配置
${Green_font_prefix} 11. ${Font_color_suffix}修改 多端口用户配置
${Green_font_prefix} 12. ${Font_color_suffix}删除 多端口用户配置
——————————————————
${Green_font_prefix} 13. ${Font_color_suffix}启动 ShadowsocksR
${Green_font_prefix} 14. ${Font_color_suffix}停止 ShadowsocksR
${Green_font_prefix} 15. ${Font_color_suffix}重启 ShadowsocksR
${Green_font_prefix} 16. ${Font_color_suffix}查看 ShadowsocksR 状态
${Green_font_prefix} 17. ${Font_color_suffix}查看 ShadowsocksR 日志
——————————————————
${Green_font_prefix} 18. ${Font_color_suffix}安装 ${Word_serverspeeder}
${Green_font_prefix} 19. ${Font_color_suffix}停止 ${Word_serverspeeder}
${Green_font_prefix} 20. ${Font_color_suffix}重启 ${Word_serverspeeder}
${Green_font_prefix} 21. ${Font_color_suffix}查看 ${Word_serverspeeder} 状态
${Green_font_prefix} 22. ${Font_color_suffix}卸载 ${Word_serverspeeder}
——————————————————"
Menu_options_bbr="${Green_font_prefix} 23. ${Font_color_suffix}安装 BBR(需更换内核, 存在风险)"
Menu_options_other="${Green_font_prefix} 24. ${Font_color_suffix}封禁 BT/PT/垃圾邮件(SPAM)
${Green_font_prefix} 25. ${Font_color_suffix}设置 ShadowsocksR 定时重启
${Green_font_prefix} 26. ${Font_color_suffix}设置 ShadowsocksR 设备数限制
${Green_font_prefix} 27. ${Font_color_suffix}设置 ShadowsocksR 速度限制
——————————————————
${Green_font_prefix} 0. ${Font_color_suffix}The scripting language is English
注意事项: ${Word_serverspeeder}/BBR 不支持 OpenVZ !"
else
Word_default="default"
Word_unlimited="unlimited"
Word_user="user"
Word_port="port"
Word_pass="pass"
Word_method="method"
Word_protocol="protocol"
Word_obfs="obfs"
Word_ss_like=" SS Like"
Word_ss_qr_code=" SS QRcode"
Word_ssr_like=" SSR Like"
Word_ssr_qr_code=" SSR QRcode"
Word_single_port="single_port"
Word_multi_port="multi_port"
Word_current_mode="Current_mode"
Word_current_status="Current_status"
Word_number_of_devices="number of devices"
Word_number_of_devices_limit="number of devices limit"
Word_single_threaded_speed_limit="single-threaded speed limit"
Word_port_total_speed_limit="port total speed limit"
Word_the_installation_is_complete="The installation is complete"
Word_installation_failed="Installation failed"
Word_uninstall_is_complete="Uninstall is complete"
Word_uninstall_cancelled="Uninstall cancelled..."
Word_canceled="Canceled..."
Word_cancel="cancel"
Word_startup_failed="Startup failed"
Word_stop_failing="Stop failing"
Word_stopped="Stopped"
Word_installed="Installed"
Word_not_installed="Not installed"
Word_has_started="Has started"
Word_have_not_started="Have not started"
Word_running="Running"
Word_not_running="Not running"
Word_info="Info"
Word_error="Error"
Word_Prompt="Prompt"
Word_timing_interval="Timing interval"
Word_and="and"
Word_but="but"
Word_serverspeeder="ServerSpeeder"
Info_switch_single_port_mode="Are you sure you want to switch mode to ${Word_single_port} ?[y/N]"
Info_switch_multi_port_mode="Are you sure you want to switch mode to Word_multi_port ?[y/N]"
Info_input_port="Please enter ShadowsocksR ${Word_port} [1-65535]"
Info_input_pass="Please enter ShadowsocksR ${Word_pass}"
Info_input_method="Please enter the number to select ShadowsocksR ${Word_method}"
Info_input_protocol="Please enter the number to select ShadowsocksR ${Word_protocol}( auth_aes128_* 以后的协议不再支持 兼容原版 )"
Info_input_number_of_devices="Please enter the number of devices that ShadowsocksR ports want to restrict (${Green_font_prefix} Auth_ * protocol is not compatible with the original version is valid! ${Font_color_suffix})"
Prompt_number_of_devices="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}The number of devices is limited, referring to the number of clients that can be linked per port (multi_port mode, each port is independently calculated)."
Info_input_obfs="Please enter the number to select ShadowsocksR ${Word_obfs}"
Info_protocol_compatible="It is compatible with the original set protocol? ( _compatible ) [Y/n] :"
Info_obfs_compatible="It is compatible with the original set obfs? ( _compatible ) [Y/n] :"
Info_protocol_obfs_compatible="It is compatible with the original set protocol / obfs? ( _compatible ) [Y/n] :"
Info_input_single_threaded_speed_limit="Please enter the maximum speed of each port you want to set for a single thread (in KB / S)"
Prompt_input_single_threaded_speed_limit="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}This refers to the limit of each port single-threaded limit, multi-threaded that is invalid."
Info_total_port_speed_limit="Please enter the maximum speed limit for each port you want to set (in KB / S)"
Prompt_total_port_speed_limit="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}This refers to the total speed limit per port, the overall speed limit for a single port."
Info_input_modify_the_type="Please enter a number to select the type you want to modify :
1. Modify ${Word_port}/${Word_pass}
2. Modify ${Word_method}/${Word_protocol}/${Word_obfs}"
info_input_select_user_id_modified="Please select and enter the user ID you want to modify :"
Info_input_select_user_id_del="Please select and enter the user ID you want to delete :"
Prompt_method_protocol_obfs_modified="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} ShadowsocksR ${Word_method}/${Word_protocol}/${Word_obfs} has been modified!"
Info_jq_installation_is_complete="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} JSON parser JQ has been installed, continue ..."
Info_jq_is_installed="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} JSON parser JQ installed, continues ..."
Info_uninstall_ssr="Sure you want to uninstall ShadowsocksR ? [y/N]"
Info_uninstall_server_speeder="Sure you want to uninstall ${Word_serverspeeder} ? [y/N]"
Info_install_bbr="Sure you want to install the BBR ? [y/n]"
Info_install_bbr_0="${Green_font_prefix} [Before installation, please note the following points] ${Font_color_suffix}
1. Install BBR, need to replace the kernel, there is a risk of replacement failure (can not boot) !
2. This script only supports Debian / Ubuntu system replacement kernel, OpenVZ virtualization does not support the replacement of the kernel !
3. In the process of replacing the kernel, you will be prompted to [ terminate the uninstall kernel ], Please select [${Green_font_prefix} NO ${Font_color_suffix}]!
4. After installing BBR and restart, you need to re-run the script to open BBR [${Green_font_prefix} bash bbr.sh start ${Font_color_suffix}] !"
Info_input_set_crontab_interval="Please enter the interval at which ShadowsocksR reboots regularly"
Info_input_set_crontab_interval_default="Every morning at 2:30 am [0 2 * * *]"
Info_set_crontab_interval_0="${Green_font_prefix} Format Description : ${Font_color_suffix}
Format: ${Green_font_prefix} * * * * * ${Font_color_suffix}, corresponding to ${Green_font_prefix} minutes / hour / day / month / week ${Font_color_suffix}
Example: ${Green_font_prefix}30 2 * * * ${Font_color_suffix}, every day, 2:30 am, restart once
Example: ${Green_font_prefix}30 2 * / 3 * * ${Font_color_suffix}, every 3 days, 2:30 am, restart once
Example: ${Green_font_prefix}30 * / 2 * * * ${Font_color_suffix}, every day, every two hours at 30 minutes, restart once"
Info_no_cron_installed="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} Detected no installation of corn, started to install ..."
Info_input_set_cron="Please enter a number to choose what you want to do
1. Add a timed task
2. Delete the timed task
${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}Currently only add a regular restart task."
Info_set_corn_status="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} There are currently no scheduled reboot task !"
Info_set_corn_del_success="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} Corn Remove the timing reboot mission success !"
Info_set_corn_add_success="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} Timed restart task was added successfully !"
Info_limit_the_number_of_devices="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} ShadowsocksR device limit has been modified !"
Info_port_speed_limit="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} ShadowsocksR port speed limit has been modified !"
Info_switch_language_english="Are you sure you want to switch the script language to English ? [y/n]"
Info_switch_language_chinese="确定要切换脚本语言为 中文 ? [y/n]"
Info_switch_language_1="${Green_font_prefix} [${Word_info}] ${Font_color_suffix} 重新运行脚本即可看到切换后的语言 !"
Errpr_input_num_error="${Red_font_prefix}[${Word_error}]${Font_color_suffix} Please enter the correct number !"
Error_not_install_ssr="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} No installation ShadowsocksR, please check !"
Error_ssr_installed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR is installed !"
Error_no_multi_port_users_were_found="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} Do not find multi_port users, please check !"
Error_jq_installation_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} JSON parser JQ installation failed !"
Error_does_not_support_the_system="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} This script does not support the current system !"
Error_ssr_download_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR download failed !"
Error_ssr_failed_to_start="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR failed to start !"
Error_the_current_mode_is_single_port="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} The current mode is single port, please check !"
Error_the_current_mode_is_multi_port="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} The current mode is multi_port, please check !"
Error_multi_port_user_remaining_one="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} The current multi_port users only one, can not be deleted !"
Error_startup_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ShadowsocksR failed to start, please check the log !"
Error_no_log_found="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} Did not find the log file, please check it out !"
Error_server_speeder_installed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ${Word_serverspeeder} installed !"
Error_server_speeder_installation_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ${Word_serverspeeder} installation failed !"
Error_server_speeder_not_installed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} ${Word_serverspeeder} is not installed, please check !"
Error_cron_installation_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} Corn installation failed !"
Error_set_corn_del_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} Delete the scheduled reboot task fails !"
Error_set_corn_add_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} Timed restart task failed to add !"
Error_set_corn_Write_failed="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} Timed restart script write failed !"
Error_limit_the_number_of_devices_1="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} The current protocol is compatible with the original (_compatible), limit the number of devices is invalid !"
Error_limit_the_number_of_devices_2="${Red_font_prefix} [${Word_error}] ${Font_color_suffix} The current agreement is the original (origin), limit the number of devices is invalid !"
Prompt_method_libsodium="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix} Chacha20-* and other encryption methods need to install libsodium support library, otherwise it will fail to start !"
Prompt_any_key="Please press any key to continue, if the configuration error please use Ctrl + C exit."
Prompt_check_if_the_configuration_is_incorrect="请检查Shadowsocks账号配置是否有误 !"
Prompt_your_account_configuration="Your ShadowsocksR account configuration :"
Prompt_ssr_status_on="ShadowsocksR is running !"
Prompt_ssr_status_off="ShadowsocksR is not running !"
Prompt_tip="${Green_font_prefix} ${Word_Prompt}: ${Font_color_suffix}
Browser, open the QRcode link, you can see the QRcode picture.
Protocols and confusion behind [_compatible], referring to the original compatible Shadowsocks protocol / obfs."
Prompt_total_number_of_users="Current total number of users:"
Prompt_total_number_of_ip="The total number of currently linked IPs is:"
Prompt_the_currently_connected_ip="The currently connected IP:"
Prompt_total_number_of_ip_number="IP number:"
Prompt_modify_multi_port_user="multi_port users have modified !"
Prompt_add_multi_port_user="multi_port users have added !"
Prompt_del_multi_port_user="multi_port user has been deleted !"
Prompt_log="Use ${Red_font_prefix} Ctrl+C ${Font_color_suffix} to exit View Log !"
Prompt_switch_language_chinese=" The current scripting language: English"
Prompt_switch_language_english=" 当前脚本语言为: 中文"
#菜单
Menu_prompt_1="Please enter a number to select the corresponding option"
Menu_prompt_2="(Please enter numbers 0-27): "
Menu_prompt_3="Please select and enter numbers 0-27 !"
Menu_options="${Green_font_prefix} 1. ${Font_color_suffix}Install Shadowsocks
${Green_font_prefix} 2. ${Font_color_suffix}Install libsodium (chacha20)
${Green_font_prefix} 3. ${Font_color_suffix}Display account information
${Green_font_prefix} 4. ${Font_color_suffix}Display connection information
${Green_font_prefix} 5. ${Font_color_suffix}Modify single-port user configuration
${Green_font_prefix} 6. ${Font_color_suffix}Manually modify user profiles
${Green_font_prefix} 7. ${Font_color_suffix}Uninstall Shadowsocks
${Green_font_prefix} 8. ${Font_color_suffix}Update Shadowsocks
——————————————————
${Green_font_prefix} 9. ${Font_color_suffix}Switch single / multi port mode
${Green_font_prefix} 10. ${Font_color_suffix}Add a multi_port user configuration
${Green_font_prefix} 11. ${Font_color_suffix}Modify multi_port user configuration
${Green_font_prefix} 12. ${Font_color_suffix}Remove the multi_port user configuration
——————————————————
${Green_font_prefix} 13. ${Font_color_suffix}Start Shadowsocks
${Green_font_prefix} 14. ${Font_color_suffix}Stop Shadowsocks
${Green_font_prefix} 15. ${Font_color_suffix}Restart Shadowsocks
${Green_font_prefix} 16. ${Font_color_suffix}View the ShadowsocksR state
${Green_font_prefix} 17. ${Font_color_suffix}View the ShadowsocksR log
——————————————————
${Green_font_prefix} 18. ${Font_color_suffix}Install ${Word_serverspeeder}
${Green_font_prefix} 19. ${Font_color_suffix}Stop ${Word_serverspeeder}
${Green_font_prefix} 20. ${Font_color_suffix}Restart ${Word_serverspeeder}
${Green_font_prefix} 21. ${Font_color_suffix}View the ${Word_serverspeeder} state
${Green_font_prefix} 22. ${Font_color_suffix}Uninstall ${Word_serverspeeder}
——————————————————"
Menu_options_bbr="${Green_font_prefix} 23. ${Font_color_suffix}Install BBR(Need to replace the kernel, there is a risk)"
Menu_options_other="${Green_font_prefix} 24. ${Font_color_suffix}Banned BT/PT/SPAM
${Green_font_prefix} 25. ${Font_color_suffix}Set ShadowsocksR scheduled reboot
${Green_font_prefix} 26. ${Font_color_suffix}Set the ShadowsocksR device limit
${Green_font_prefix} 27. ${Font_color_suffix}Set the ShadowsocksR speed limit
——————————————————
${Green_font_prefix} 0. ${Font_color_suffix}切换 脚本语言为中文
Note: ${Word_serverspeeder} / BBR does not support OpenVZ !"
fi
Menu_status_1=" ${Word_current_status}: ${Green_font_prefix} ${Word_installed} ${Font_color_suffix} ${Word_and} ${Green_font_prefix} ${Word_has_started} ${Font_color_suffix}"
Menu_status_2=" ${Word_current_status}: ${Green_font_prefix} ${Word_installed} ${Font_color_suffix} ${Word_but} ${Red_font_prefix} ${Word_have_not_started} ${Font_color_suffix}"
Menu_status_3=" ${Word_current_status}: ${Red_font_prefix} ${Word_not_installed} ${Font_color_suffix}"
Menu_mode_1=" ${Word_current_mode}: ${Green_font_prefix} ${Word_single_port} ${Font_color_suffix}"
Menu_mode_2=" ${Word_current_mode}: ${Green_font_prefix} ${Word_multi_port} ${Font_color_suffix}"
}
#检查系统
check_sys(){
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"
fi
#bit=`uname -m`
}
SSR_install_status(){
[[ ! -e $config_user_file ]] && echo -e "${Error_not_install_ssr}" && exit 1
}
#获取IP
getIP(){
ip=`curl -m 10 -s "ipinfo.io/ip"`
#ip=`wget -qO- -t1 -T2 ipinfo.io/ip`
[[ -z "$ip" ]] && ip="VPS_IP"
}
#获取用户账号信息
getUser(){
port=`jq '.server_port' ${config_user_file}`
password=`jq '.password' ${config_user_file} | sed 's/^.//;s/.$//'`
method=`jq '.method' ${config_user_file} | sed 's/^.//;s/.$//'`
protocol=`jq '.protocol' ${config_user_file} | sed 's/^.//;s/.$//'`
obfs=`jq '.obfs' ${config_user_file} | sed 's/^.//;s/.$//'`
protocol_param=`jq '.protocol_param' ${config_user_file} | sed 's/^.//;s/.$//'`
speed_limit_per_con=`jq '.speed_limit_per_con' ${config_user_file}`
speed_limit_per_user=`jq '.speed_limit_per_user' ${config_user_file}`
}
# 设置 端口和密码
set_port_pass(){
#设置端口
while true
do
echo -e "${Info_input_port}"
stty erase '^H' && read -p "(${Word_default}: 2333):" ssport
[[ -z "$ssport" ]] && ssport="2333"
expr ${ssport} + 0 &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${ssport} -ge 1 ]] && [[ ${ssport} -le 65535 ]]; then
echo && echo ${Separator_1} && echo -e " ${Word_port} : ${Green_font_prefix}${ssport}${Font_color_suffix}" && echo ${Separator_1} && echo
break
else
echo -e "${Errpr_input_num_error}"
fi
else
echo -e "${Errpr_input_num_error}"
fi
done
#设置密码
echo "${Info_input_pass}:"
stty erase '^H' && read -p "(${Word_default}: doub.io):" sspwd
[[ -z "${sspwd}" ]] && sspwd="doub.io"
echo && echo ${Separator_1} && echo -e " ${Word_pass} : ${Green_font_prefix}${sspwd}${Font_color_suffix}" && echo ${Separator_1} && echo
}
# 设置 加密方式、协议和混淆等
set_others(){
#设置加密方式
echo "${Info_input_method}"
echo " 1. rc4-md5"
echo " 2. aes-128-ctr"
echo " 3. aes-256-ctr"
echo " 4. aes-256-cfb"
echo " 5. aes-256-cfb8"
echo " 6. camellia-256-cfb"
echo " 7. chacha20"
echo " 8. chacha20-ietf"
echo -e "${Prompt_method_libsodium}"
echo
stty erase '^H' && read -p "(${Word_default}: 2. aes-128-ctr):" ssmethod
[[ -z "${ssmethod}" ]] && ssmethod="2"
if [[ ${ssmethod} == "1" ]]; then
ssmethod="rc4-md5"
elif [[ ${ssmethod} == "2" ]]; then
ssmethod="aes-128-ctr"
elif [[ ${ssmethod} == "3" ]]; then
ssmethod="aes-256-ctr"
elif [[ ${ssmethod} == "4" ]]; then
ssmethod="aes-256-cfb"
elif [[ ${ssmethod} == "5" ]]; then
ssmethod="aes-256-cfb8"
elif [[ ${ssmethod} == "6" ]]; then
ssmethod="camellia-256-cfb"
elif [[ ${ssmethod} == "7" ]]; then
ssmethod="chacha20"
elif [[ ${ssmethod} == "8" ]]; then
ssmethod="chacha20-ietf"
else
ssmethod="aes-128-ctr"
fi
echo && echo ${Separator_1} && echo -e " ${Word_method} : ${Green_font_prefix}${ssmethod}${Font_color_suffix}" && echo ${Separator_1} && echo
#设置协议
echo "${Info_input_protocol}"
echo " 1. origin"
echo " 2. auth_sha1_v4"
echo " 3. auth_aes128_md5"
echo " 4. auth_aes128_sha1"
echo
stty erase '^H' && read -p "(${Word_default}: 2. auth_sha1_v4):" ssprotocol
[[ -z "${ssprotocol}" ]] && ssprotocol="2"
if [[ ${ssprotocol} == "1" ]]; then
ssprotocol="origin"
elif [[ ${ssprotocol} == "2" ]]; then
ssprotocol="auth_sha1_v4"
elif [[ ${ssprotocol} == "3" ]]; then
ssprotocol="auth_aes128_md5"
elif [[ ${ssprotocol} == "4" ]]; then
ssprotocol="auth_aes128_sha1"
else
ssprotocol="auth_sha1_v4"
fi
echo && echo ${Separator_1} && echo -e " ${Word_protocol} : ${Green_font_prefix}${ssprotocol}${Font_color_suffix}" && echo ${Separator_1} && echo
#设置混淆
echo "${Info_input_obfs}"
echo " 1. plain"
echo " 2. http_simple"
echo " 3. http_post"
echo " 4. random_head"
echo " 5. tls1.2_ticket_auth"
echo
stty erase '^H' && read -p "(${Word_default}: 5. tls1.2_ticket_auth):" ssobfs
[[ -z "${ssobfs}" ]] && ssobfs="5"
if [[ ${ssobfs} == "1" ]]; then
ssobfs="plain"
elif [[ ${ssobfs} == "2" ]]; then
ssobfs="http_simple"
elif [[ ${ssobfs} == "3" ]]; then
ssobfs="http_post"
elif [[ ${ssobfs} == "4" ]]; then
ssobfs="random_head"
elif [[ ${ssobfs} == "5" ]]; then
ssobfs="tls1.2_ticket_auth"
else
ssobfs="tls1.2_ticket_auth"
fi
echo && echo ${Separator_1} && echo -e " ${Word_obfs} : ${Green_font_prefix}${ssobfs}${Font_color_suffix}" && echo ${Separator_1} && echo
#询问是否设置 ${Word_obfs} 兼容原版
if [[ ${ssprotocol} != "origin" ]]; then
if [[ ${ssobfs} != "plain" ]]; then
if [[ ${ssprotocol} == "verify_sha1" ]] || [[ ${ssprotocol} == "auth_sha1_v2" ]] || [[ ${ssprotocol} == "auth_sha1_v4" ]]; then
stty erase '^H' && read -p "${Info_protocol_obfs_compatible}" yn1
[[ -z "${yn1}" ]] && yn1="y"
[[ $yn1 == [Yy] ]] && ssobfs=${ssobfs}"_compatible" && ssprotocol=${ssprotocol}"_compatible"
else
stty erase '^H' && read -p "${Info_obfs_compatible}" yn1
[[ -z "${yn1}" ]] && yn1="y"
[[ $yn1 == [Yy] ]] && ssobfs=${ssobfs}"_compatible"
fi
else
if [[ ${ssprotocol} == "verify_sha1" ]] || [[ ${ssprotocol} == "auth_sha1_v2" ]] || [[ ${ssprotocol} == "auth_sha1_v4" ]]; then
stty erase '^H' && read -p "${Info_protocol_compatible}" yn1
[[ -z "${yn1}" ]] && yn1="y"
[[ $yn1 == [Yy] ]] && ssprotocol=${ssprotocol}"_compatible"
fi
fi
else
if [[ ${ssobfs} != "plain" ]]; then
stty erase '^H' && read -p "${Info_obfs_compatible}" yn1
[[ -z "${yn1}" ]] && yn1="y"
[[ $yn1 == [Yy] ]] && ssobfs=${ssobfs}"_compatible"
fi
fi
if [[ ${ssprotocol} != "origin" ]]; then
while true
do
echo
echo -e "${Info_input_number_of_devices}"
echo -e "${Prompt_number_of_devices}"
stty erase '^H' && read -p "(${Word_default}: ${Word_unlimited}):" ssprotocol_param
[[ -z "$ssprotocol_param" ]] && ssprotocol_param="" && break
expr ${ssprotocol_param} + 0 &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${ssprotocol_param} -ge 1 ]] && [[ ${ssprotocol_param} -le 99999 ]]; then
echo && echo ${Separator_1} && echo -e " ${Word_number_of_devices} : ${Green_font_prefix}${ssprotocol_param}${Font_color_suffix}" && echo ${Separator_1} && echo
break
else
echo "${Errpr_input_num_error}"
fi
else
echo "${Errpr_input_num_error}"
fi
done
fi
# 设置单线程限速
while true
do
echo
echo -e "${Info_input_single_threaded_speed_limit}"
echo -e "${Prompt_input_single_threaded_speed_limit}"
stty erase '^H' && read -p "(${Word_default}: ${Word_unlimited}):" ssspeed_limit_per_con
[[ -z "$ssspeed_limit_per_con" ]] && ssspeed_limit_per_con=0 && break
expr ${ssspeed_limit_per_con} + 0 &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${ssspeed_limit_per_con} -ge 1 ]] && [[ ${ssspeed_limit_per_con} -le 99999 ]]; then
echo && echo ${Separator_1} && echo -e " ${Word_single_threaded_speed_limit} : ${Green_font_prefix}${ssspeed_limit_per_con} KB/S${Font_color_suffix}" && echo ${Separator_1} && echo
break
else
echo "${Errpr_input_num_error}"
fi
else
echo "${Errpr_input_num_error}"
fi
done
# 设置端口总限速
while true
do
echo
echo -e "${Info_total_port_speed_limit}"
echo -e "${Prompt_total_port_speed_limit}"
stty erase '^H' && read -p "(${Word_default}: ${Word_unlimited}):" ssspeed_limit_per_user
[[ -z "$ssspeed_limit_per_user" ]] && ssspeed_limit_per_user=0 && break
expr ${ssspeed_limit_per_user} + 0 &>/dev/null
if [[ $? -eq 0 ]]; then
if [[ ${ssspeed_limit_per_user} -ge 1 ]] && [[ ${ssspeed_limit_per_user} -le 99999 ]]; then
echo && echo ${Separator_1} && echo -e " ${Word_port_total_speed_limit} : ${Green_font_prefix}${ssspeed_limit_per_user} KB/S${Font_color_suffix}" && echo ${Separator_1} && echo
break
else
echo "${Errpr_input_num_error}"
fi
else
echo "${Errpr_input_num_error}"
fi
done
}
#设置用户账号信息
setUser(){
set_port_pass
set_others
#最后确认
[[ "${ssprotocol_param}" == "" ]] && ssprotocol_param="0(${Word_unlimited})"
echo && echo ${Separator_1}
echo " ${Prompt_check_if_the_configuration_is_incorrect}" && echo
echo -e " ${Word_port}\t : ${Green_font_prefix}${ssport}${Font_color_suffix}"
echo -e " ${Word_pass}\t : ${Green_font_prefix}${sspwd}${Font_color_suffix}"
echo -e " ${Word_method}\t : ${Green_font_prefix}${ssmethod}${Font_color_suffix}"
echo -e " ${Word_protocol}\t : ${Green_font_prefix}${ssprotocol}${Font_color_suffix}"
echo -e " ${Word_obfs}\t : ${Green_font_prefix}${ssobfs} ${Font_color_suffix}"
echo -e " ${Word_number_of_devices_limit} : ${Green_font_prefix}${ssprotocol_param}${Font_color_suffix}"
echo -e " ${Word_number_of_devices_limit} : ${Green_font_prefix}${ssspeed_limit_per_con} KB/S${Font_color_suffix}"
echo -e " ${Word_port_total_speed_limit} : ${Green_font_prefix}${ssspeed_limit_per_user} KB/S${Font_color_suffix}"
echo ${Separator_1} && echo
stty erase '^H' && read -p "${Prompt_any_key}" var
[[ "${ssprotocol_param}" = "0(${Word_unlimited})" ]] && ssprotocol_param=""
}
ss_link_qr(){
SSbase64=`echo -n "${method}:${password}@${ip}:${port}" | base64 | sed ':a;N;s/\n/ /g;ta' | sed 's/ //g'`
SSurl="ss://"${SSbase64}
SSQRcode="http://doub.pw/qr/qr.php?text="${SSurl}
ss_link="${Word_ss_like} : ${Green_font_prefix}${SSurl}${Font_color_suffix} \n${Word_ss_qr_code} : ${Green_font_prefix}${SSQRcode}${Font_color_suffix}"
}
ssr_link_qr(){
SSRprotocol=`echo ${protocol} | sed 's/_compatible//g'`
SSRobfs=`echo ${obfs} | sed 's/_compatible//g'`
SSRPWDbase64=`echo -n "${password}" | base64 | sed ':a;N;s/\n/ /g;ta' | sed 's/ //g'`
SSRbase64=`echo -n "${ip}:${port}:${SSRprotocol}:${method}:${SSRobfs}:${SSRPWDbase64}" | base64 | sed ':a;N;s/\n/ /g;ta' | sed 's/ //g'`
SSRurl="ssr://"${SSRbase64}
SSRQRcode="http://doub.pw/qr/qr.php?text="${SSRurl}
ssr_link="${Word_ssr_like} : ${Green_font_prefix}${SSRurl}${Font_color_suffix} \n${Word_ssr_qr_code} : ${Green_font_prefix}${SSRQRcode}${Font_color_suffix} \n "
}
ss_link_qr_1(){
SSbase64=`echo -n "${method}:${user_password}@${ip}:${user_port}" | base64 | sed ':a;N;s/\n/ /g;ta' | sed 's/ //g'`
#echo -e "${user_port}" && echo -e "${user_password}" && echo -e "${SSbase64}"
SSurl="ss://"${SSbase64}
SSQRcode="http://doub.pw/qr/qr.php?text="${SSurl}
ss_link="${Word_ss_like} : ${Green_font_prefix}${SSurl}${Font_color_suffix} \n${Word_ss_qr_code} : ${Green_font_prefix}${SSQRcode}${Font_color_suffix}"
}
ssr_link_qr_1(){
SSRprotocol=`echo ${protocol} | sed 's/_compatible//g'`
SSRobfs=`echo ${obfs} | sed 's/_compatible//g'`
SSRPWDbase64=`echo -n "${user_password}" | base64 | sed ':a;N;s/\n/ /g;ta' | sed 's/ //g'`
SSRbase64=`echo -n "${ip}:${user_port}:${SSRprotocol}:${method}:${SSRobfs}:${SSRPWDbase64}" | base64 | sed ':a;N;s/\n/ /g;ta' | sed 's/ //g'`
#echo -e "${user_port}" && echo -e "${user_password}" && echo -e "${SSRbase64}"
SSRurl="ssr://"${SSRbase64}
SSRQRcode="http://doub.pw/qr/qr.php?text="${SSRurl}
ssr_link="${Word_ssr_like} : ${Green_font_prefix}${SSRurl}${Font_color_suffix} \n${Word_ssr_qr_code} : ${Green_font_prefix}${SSRQRcode}${Font_color_suffix} \n "
}
#显示用户账号信息
viewUser(){
SSR_install_status
PID=`ps -ef |grep -v grep | grep server.py |awk '{print $2}'`
if [[ -z "${PID}" ]]; then
ssr_status="${Red_font_prefix} ${Word_current_status}: ${Font_color_suffix} ShadowsocksR ${Word_not_running} !"
else
ssr_status="${Green_font_prefix} ${Word_current_status}: ${Font_color_suffix} ShadowsocksR ${Word_running} !"
fi
getIP
now_mode=`jq '.port_password' ${config_user_file}`
if [[ "${now_mode}" = "null" ]]; then
getUser
SSprotocol=`echo ${protocol} | awk -F "_" '{print $NF}'`
SSobfs=`echo ${obfs} | awk -F "_" '{print $NF}'`
if [[ ${protocol} = "origin" ]]; then
if [[ ${obfs} = "plain" ]]; then
ss_link_qr
ssr_link=""
else
if [[ ${SSobfs} != "compatible" ]]; then
ss_link=""
else
ss_link_qr
fi
fi
else
if [[ ${SSprotocol} != "compatible" ]]; then
ss_link=""
else
if [[ ${SSobfs} != "compatible" ]]; then
if [[ ${SSobfs} = "plain" ]]; then
ss_link_qr
else
ss_link=""
fi
else
ss_link_qr
fi
fi
fi
ssr_link_qr
[[ -z ${protocol_param} ]] && protocol_param="0(${Word_unlimited})"
clear
echo "==================================================="
echo
echo -e " ${Prompt_your_account_configuration}"
echo
echo -e " I P\t : ${Green_font_prefix}${ip}${Font_color_suffix}"
echo -e " ${Word_port}\t : ${Green_font_prefix}${port}${Font_color_suffix}"
echo -e " ${Word_pass}\t : ${Green_font_prefix}${password}${Font_color_suffix}"
echo -e " ${Word_method}\t : ${Green_font_prefix}${method}${Font_color_suffix}"
echo -e " ${Word_protocol}\t : ${Green_font_prefix}${protocol}${Font_color_suffix}"
echo -e " ${Word_obfs}\t : ${Green_font_prefix}${obfs}${Font_color_suffix}"
echo -e " ${Word_number_of_devices_limit} : ${Green_font_prefix}${protocol_param}${Font_color_suffix}"
echo -e " ${Word_number_of_devices_limit} : ${Green_font_prefix}${speed_limit_per_con} KB/S${Font_color_suffix}"
echo -e " ${Word_port_total_speed_limit} : ${Green_font_prefix}${speed_limit_per_user} KB/S${Font_color_suffix}"
echo -e "${ss_link}"
echo -e "${ssr_link}"
echo -e "${Prompt_tip}"
echo
echo -e ${ssr_status}
echo
echo "==================================================="
else
getUser
[[ -z ${protocol_param} ]] && protocol_param="0(${Word_unlimited})"
clear
echo "==================================================="
echo
echo -e " ${Prompt_your_account_configuration}"
echo
echo -e " I P\t : ${Green_font_prefix}${ip}${Font_color_suffix}"
echo -e " ${Word_method}\t : ${Green_font_prefix}${method}${Font_color_suffix}"
echo -e " ${Word_protocol}\t : ${Green_font_prefix}${protocol}${Font_color_suffix}"
echo -e " ${Word_obfs}\t : ${Green_font_prefix}${obfs}${Font_color_suffix}"
echo -e " ${Word_number_of_devices_limit} : ${Green_font_prefix}${protocol_param}${Font_color_suffix}"
echo -e " ${Word_number_of_devices_limit} : ${Green_font_prefix}${speed_limit_per_con} KB/S${Font_color_suffix}"
echo -e " ${Word_port_total_speed_limit} : ${Green_font_prefix}${speed_limit_per_user} KB/S${Font_color_suffix}"
echo
user_total=`jq '.port_password' ${config_user_file} | sed '$d' | sed "1d" | wc -l`
[[ ${socat_total} = "0" ]] && echo -e "${Red_font_prefix} [${Word_error}] ${Font_color_suffix} 没有发现 多端口用户,请检查 !" && exit 1
user_id=0
check_sys
if [[ ${release} = "centos" ]]; then
for((integer = 1; integer <= ${user_total}; integer++))
do
user_port=`jq '.port_password' ${config_user_file} | sed '$d' | sed "1d" | awk -F ":" '{print $1}' | sed -n "${integer}p" | perl -e 'while($_=<>){ /\"(.*)\"/; print $1;}'`
user_password=`jq '.port_password' ${config_user_file} | sed '$d' | sed "1d" | awk -F ":" '{print $2}' | sed -n "${integer}p" | perl -e 'while($_=<>){ /\"(.*)\"/; print $1;}'`
user_id=$[$user_id+1]
#echo -e ${user_port} && echo -e ${user_password} && echo -e ${user_id}
SSprotocol=`echo ${protocol} | awk -F "_" '{print $NF}'`
SSobfs=`echo ${obfs} | awk -F "_" '{print $NF}'`
if [[ ${protocol} = "origin" ]]; then
if [[ ${obfs} = "plain" ]]; then
ss_link_qr_1
ssr_link=""
else
if [[ ${SSobfs} != "compatible" ]]; then
ss_link=""
else
ss_link_qr_1
fi
fi
else
if [[ ${SSprotocol} != "compatible" ]]; then
ss_link=""
else
if [[ ${SSobfs} != "compatible" ]]; then
if [[ ${SSobfs} = "plain" ]]; then
ss_link_qr_1
else
ss_link=""
fi
else
ss_link_qr_1
fi
fi
fi
ssr_link_qr_1
echo -e " ——————————${Green_font_prefix} ${Word_user} ${user_id} ${Font_color_suffix} ——————————"
echo -e " ${Word_port}\t : ${Green_font_prefix}${user_port}${Font_color_suffix}"
echo -e " ${Word_pass}\t : ${Green_font_prefix}${user_password}${Font_color_suffix}"
echo -e "${ss_link}"
echo -e "${ssr_link}"
done
else
for((integer = ${user_total}; integer >= 1; integer--))
do
user_port=`jq '.port_password' ${config_user_file} | sed '$d' | sed "1d" | awk -F ":" '{print $1}' | sed -n "${integer}p" | perl -e 'while($_=<>){ /\"(.*)\"/; print $1;}'`
user_password=`jq '.port_password' ${config_user_file} | sed '$d' | sed "1d" | awk -F ":" '{print $2}' | sed -n "${integer}p" | perl -e 'while($_=<>){ /\"(.*)\"/; print $1;}'`
user_id=$[$user_id+1]
SSprotocol=`echo ${protocol} | awk -F "_" '{print $NF}'`
SSobfs=`echo ${obfs} | awk -F "_" '{print $NF}'`
if [[ ${protocol} = "origin" ]]; then
if [[ ${obfs} = "plain" ]]; then
ss_link_qr_1
ssr_link=""
else
if [[ ${SSobfs} != "compatible" ]]; then
ss_link=""
else
ss_link_qr_1
fi
fi
else
if [[ ${SSprotocol} != "compatible" ]]; then
ss_link=""
else
if [[ ${SSobfs} != "compatible" ]]; then
if [[ ${SSobfs} = "plain" ]]; then
ss_link_qr_1
else
ss_link=""
fi
else
ss_link_qr_1
fi
fi
fi
ssr_link_qr_1
echo -e " —————————— ${Green_font_prefix} ${Word_user} ${user_id} ${Font_color_suffix} ——————————"
echo -e " ${Word_port}\t : ${Green_font_prefix}${user_port}${Font_color_suffix}"
echo -e " ${Word_pass}\t : ${Green_font_prefix}${user_password}${Font_color_suffix}"
echo -e "${ss_link}"
echo -e "${ssr_link}"
done
fi
echo -e "${Prompt_tip}"
echo
echo -e ${ssr_status}
echo
echo "==================================================="
fi
}
debian_apt(){
apt-get update
apt-get install -y python-pip python-m2crypto curl unzip vim git gcc build-essential make
}
centos_yum(){
yum update
yum install -y python-pip python-m2crypto curl unzip vim git gcc make
}
JQ_install(){
JQ_ver=`jq -V`
if [[ -z ${JQ_ver} ]]; then
#wget --no-check-certificate -N "https://softs.pw/Bash/other/jq-1.5.tar.gz"
wget --no-check-certificate -N "https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/other/jq-1.5.tar.gz"
tar -xzf jq-1.5.tar.gz && cd jq-1.5
./configure --disable-maintainer-mode && make && make install
ldconfig
cd .. && rm -rf jq-1.5.tar.gz && rm -rf jq-1.5
JQ_ver=`jq -V`
[[ -z ${JQ_ver} ]]&& echo -e "${Error_jq_installation_failed}" && exit 1
echo -e "${Info_jq_installation_is_complete}"
else
echo -e "${Info_jq_is_installed}"
fi
}
rc.local_ss_set(){
#添加开机启动
if [[ ${release} = "centos" ]]; then
chmod +x /etc/rc.d/rc.local
#sed -i '/cd \/etc\/shadowsocksr\/shadowsocks\//d' /etc/rc.d/rc.local
#sed -i '/nohup python server.py a >> ssserver.log 2>&1 &/d' /etc/rc.d/rc.local
sed -i '/shadowsocksr/d' /etc/rc.d/rc.local
sed -i '/python server.py/d' /etc/rc.d/rc.local
echo -e "cd ${ssr_ss_file} && nohup python server.py a >> ssserver.log 2>&1 &" >> /etc/rc.d/rc.local
else
chmod +x /etc/rc.local
sed -i '$d' /etc/rc.local
#sed -i '/cd \/etc\/shadowsocksr\/shadowsocks\//d' /etc/rc.local
#sed -i '/nohup python server.py a >> ssserver.log 2>&1 &/d' /etc/rc.local
sed -i '/shadowsocksr/d' /etc/rc.local
sed -i '/python server.py/d' /etc/rc.local
echo -e "cd ${ssr_ss_file} && nohup python server.py a >> ssserver.log 2>&1 &" >> /etc/rc.local
echo -e "exit 0" >> /etc/rc.local
fi
}
rc.local_ss_del(){
if [[ ${release} = "centos" ]]; then
#sed -i '/cd \/etc\/shadowsocksr\/shadowsocks\//d' /etc/rc.d/rc.local
#sed -i '/nohup python server.py a >> ssserver.log 2>&1 &/d' /etc/rc.d/rc.local
sed -i '/shadowsocksr/d' /etc/rc.d/rc.local
sed -i '/python server.py/d' /etc/rc.d/rc.local
else
#sed -i '/cd \/etc\/shadowsocksr\/shadowsocks\//d' /etc/rc.local
#sed -i '/nohup python server.py a >> ssserver.log 2>&1 &/d' /etc/rc.local
sed -i '/shadowsocksr/d' /etc/rc.local
sed -i '/python server.py/d' /etc/rc.local
fi
}
rc.local_serverspeed_set(){
#添加开机启动
if [[ ${release} = "centos" ]]; then
chmod +x /etc/rc.d/rc.local
sed -i '/serverspeeder/d' /etc/rc.d/rc.local
echo -e "/serverspeeder/bin/serverSpeeder.sh start" >> /etc/rc.d/rc.local
else
chmod +x /etc/rc.local
sed -i '$d' /etc/rc.local
sed -i '/serverspeeder/d' /etc/rc.local
echo -e "/serverspeeder/bin/serverSpeeder.sh start" >> /etc/rc.local
echo -e "exit 0" >> /etc/rc.local
fi
}
rc.local_serverspeed_del(){
if [[ ${release} = "centos" ]]; then
sed -i '/serverspeeder/d' /etc/rc.d/rc.local
else
sed -i '/serverspeeder/d' /etc/rc.local
fi
}
iptables_add(){
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport ${ssport} -j ACCEPT
iptables -I INPUT -m state --state NEW -m udp -p udp --dport ${ssport} -j ACCEPT
}
iptables_del(){
iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport ${port} -j ACCEPT
iptables -D INPUT -m state --state NEW -m udp -p udp --dport ${port} -j ACCEPT
}
iptables_set(){
#删除旧端口的防火墙规则,添加新端口的规则
iptables_del
iptables_add
}
set_config_port_pass(){
sed -i 's/"server_port": '$(echo ${port})'/"server_port": '$(echo ${ssport})'/g' ${config_user_file}
sed -i 's/"password": "'$(echo ${password})'"/"password": "'$(echo ${sspwd})'"/g' ${config_user_file}
}
set_config_method_obfs_protocol(){
sed -i 's/"method": "'$(echo ${method})'"/"method": "'$(echo ${ssmethod})'"/g' ${config_user_file}
sed -i 's/"obfs": "'$(echo ${obfs})'"/"obfs": "'$(echo ${ssobfs})'"/g' ${config_user_file}
sed -i 's/"protocol": "'$(echo ${protocol})'"/"protocol": "'$(echo ${ssprotocol})'"/g' ${config_user_file}
}
set_config_protocol_param(){
sed -i 's/"protocol_param": "'$(echo ${protocol_param})'"/"protocol_param": "'$(echo ${ssprotocol_param})'"/g' ${config_user_file}
}
set_config_speed_limit_per(){
sed -i 's/"speed_limit_per_con": '$(echo ${speed_limit_per_con})'/"speed_limit_per_con": '$(echo ${ssspeed_limit_per_con})'/g' ${config_user_file}
sed -i 's/"speed_limit_per_user": '$(echo ${speed_limit_per_user})'/"speed_limit_per_user": '$(echo ${ssspeed_limit_per_user})'/g' ${config_user_file}
}
#安装ShadowsocksR
installSSR(){
[[ -e $config_user_file ]] && echo -e "${Error_ssr_installed}" && exit 1
setUser
check_sys
# 系统判断
if [[ ${release} = "debian" ]]; then
debian_apt
elif [[ ${release} = "ubuntu" ]]; then
debian_apt
elif [[ ${release} = "centos" ]]; then
centos_yum
else
echo -e "${Error_does_not_support_the_system}" && exit 1
fi
#修改DNS为8.8.8.8
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
JQ_install
cd /etc
#git config --global http.sslVerify false
env GIT_SSL_NO_VERIFY=true git clone -b manyuser https://github.com/shadowsocksr/shadowsocksr.git
[[ ! -e ${config_file} ]] && echo -e "${Error_ssr_download_failed}" && exit 1
cp ${config_file} ${config_user_file}
#修改配置文件的密码 端口 加密方式
cat > ${config_user_file}<<-EOF
{
"server": "0.0.0.0",
"server_ipv6": "::",
"server_port": ${ssport},
"local_address": "127.0.0.1",
"local_port": 1080,
"password": "${sspwd}",
"timeout": 120,