-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtaffy.sh
executable file
·2654 lines (2240 loc) · 72 KB
/
taffy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
stty erase ^?
version="v2.4.1"
#fonts color
Green="\033[32m"
Red="\033[31m"
Yellow="\033[33m"
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m'
GreenBG="\033[42;37m"
RedBG="\033[41;37m"
Font="\033[0m"
#notification information
Info="${Green}[信息]${Font}"
Warn="${Yellow}[警告]${Font}"
OK="${Green}[OK]${Font}"
Error="${Red}[错误]${Font}"
bbr_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/BBR/sysctl.conf"
website_git="https://github.com/bakasine/bakasine.github.io.git"
ukonw_url="https://raw.githubusercontent.com/bakasine/rules/master/xray/uknow.txt"
xray_install_url="https://github.com/uerax/taffy-onekey/raw/master/install-xray.sh"
xray_socks5_append_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Socks5/append.json"
xray_ss_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Shadowsocket/config.json"
xray_ss_append_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Shadowsocket/append.json"
xray_trojan_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Trojan/config.json"
xray_trojan_append_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Trojan/append.json"
xray_trojan_grpc_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Trojan-GRPC/config.json"
trojan_grpc_nginx_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Trojan-GRPC/nginx.conf"
xray_trojan_tcp_tls_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Trojan-TCP-TLS/config.json"
trojan_tcp_tls_nginx_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Trojan-TCP-TLS/nginx.conf"
xray_vmess_ws_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VMESS-WS-TLS/config.json"
vmess_ws_nginx_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VMESS-WS-TLS/nginx.conf"
vless_ws_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VLESS-WS-TLS/config.json"
vless_ws_nginx_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VLESS-WS-TLS/nginx.conf"
vless_grpc_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VLESS-GRPC/config.json"
vless_grpc_nginx_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VLESS-GRPC/nginx.conf"
vless_vision_nginx_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VLESS-TCP-XTLS-VISION/nginx.conf"
vless_vision_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VLESS-TCP-XTLS-VISION/config.json"
xray_vless_reality_tcp_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-TCP/config.json"
xray_vless_reality_tcp_append_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-TCP/append.json"
xray_vless_reality_grpc_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-GRPC/config.json"
xray_vless_reality_grpc_append_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-GRPC/append.json"
xray_vless_reality_h2_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-H2/config.json"
vless_reality_h2_append_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-H2/append.json"
xray_redirect_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Redirect/xray.json"
xray_redirect_append_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Redirect/xray_ap.json"
# SINGBOX URL START
singbox_install_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/install-singbox.sh"
singbox_cfg_path="/etc/sing-box"
singbox_cfg="${singbox_cfg_path}/config.json"
singbox_outbound=""
singbox_ss_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Shadowsocket/singbox.json"
singbox_ss_append_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Shadowsocket/singbox_ap.json"
singbox_hysteria2_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Hysteria2/singbox.json"
singbox_vless_reality_h2_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-H2/singbox.json"
singbox_vless_reality_grpc_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-GRPC/singbox.json"
singbox_vless_reality_tcp_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/REALITY-TCP/singbox.json"
singbox_vmess_ws_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/VMESS-WS-TLS/singbox.json"
singbox_trojan_tls_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Trojan-TCP-TLS/singbox.json"
singbox_trojan_tls_nginx_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Trojan-TCP-TLS/taffy.conf"
singbox_redirect_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Redirect/singbox.json"
singbox_redirect_append_config_url="https://raw.githubusercontent.com/uerax/taffy-onekey/master/config/Redirect/singbox_ap.json"
singbox_route_url="https://raw.githubusercontent.com/bakasine/rules/master/singbox/singbox.txt"
# SINGBOX URL END
xray_cfg="/usr/local/etc/xray/config.json"
xray_path="/opt/xray/"
xray_log="${xray_path}xray_log"
nginx_cfg="/etc/nginx/conf.d/taffy.conf"
web_dir="blog"
protocol_type=""
web_path="/opt/web"
ca_path="/opt/cert"
ca_crt="${ca_path}/taffy.crt"
ca_key="${ca_path}/taffy.key"
ws_path="crayfish"
ss_method=""
xray_outbound=""
INS="apt install -y"
password=""
domain=""
link=""
port="1991"
xray_onekey_install() {
is_root
get_system
if ! command -v xray >/dev/null 2>&1; then
env_install
close_firewall
xray_install
fi
if ! command -v xray >/dev/null 2>&1; then
echo -e "${Red}Xray 安装失败!!!${Font}"
exit 1
fi
xray_configure
xray_select
}
is_root() {
if [ $(id -u) == 0 ]; then
ok "进入安装流程"
apt purge needrestart -y
sleep 3
else
error "请切使用root用户执行脚本"
info "切换root用户命令: sudo su"
exit 1
fi
}
get_system() {
source '/etc/os-release'
if [[ "${ID}" == "debian" ]]; then
info "检测系统为 debian"
elif [[ "${ID}"=="ubuntu" ]]; then
info "检测系统为 ubuntu"
elif [[ "${ID}"=="centos" ]]; then
error "centos fuck out!"
exit 1
else
error "当前系统为 ${ID} ${VERSION_ID} 不在支持的系统列表内"
exit 1
fi
}
adjust_date() {
info "正在调整时区"
apt install -y locales
echo "Asia/Shanghai" > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
echo "Asia/Shanghai" > /etc/timezone
judge "时区调整"
}
env_install() {
${INS} wget lsof curl jq openssl
judge "git wget lsof curl jq openssl 安装"
}
env_install_singbox() {
${INS} wget lsof curl jq openssl
judge "wget lsof curl jq openssl 安装"
}
increase_max_handle() {
# 最大文件打开数
sed -i '/^\*\ *soft\ *nofile\ *[[:digit:]]*/d' /etc/security/limits.conf
sed -i '/^\*\ *hard\ *nofile\ *[[:digit:]]*/d' /etc/security/limits.conf
echo '* soft nofile 65536' >>/etc/security/limits.conf
echo '* hard nofile 65536' >>/etc/security/limits.conf
}
port_check() {
if [[ 0 -eq $(lsof -i:"$1" | grep -i -c "listen") ]]; then
ok "$1 端口未被占用"
sleep 1
else
error "检测到 $1 端口被占用,以下为 $1 端口占用信息"
lsof -i:"$1"
error "2s 后将尝试自动 kill 占用进程"
sleep 2
lsof -i:"$1" | awk '{print $2}' | grep -v "PID" | xargs kill -9
ok "kill 完成"
sleep 1
fi
}
close_firewall() {
if command -v iptables >/dev/null 2>&1; then
# 主要针对oracle vps
apt purge netfilter-persistent -y
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F
ok "关闭防火墙"
fi
}
nginx_install() {
# 判断是否有 nginx 命令
if ! command -v nginx >/dev/null 2>&1; then
${INS} nginx cron
judge "Nginx 安装"
else
ok "Nginx 已存在"
fi
mkdir -p ${web_path} && cd ${web_path}
git clone ${website_git} ${web_dir}
}
update_web() {
git clone ${website_git} ${web_path}/${web_dir}
}
domain_handle() {
echo -e "------------------------------------------"
read -rp "输入你的域名(eg: example.com): " domain
}
apply_certificate() {
ipv6=''
echo -e "========================================"
read -rp "是否纯IPv6域名(Y/N): " is_v6
case $is_v6 in
[yY])
ipv6='--listen-v6'
;;
*)
;;
esac
sed -i '/\/etc\/nginx\/sites-enabled\//d' /etc/nginx/nginx.conf
cat>${nginx_cfg}<<EOF
server {
listen 80;
server_name ${domain};
root ${web_path}/${web_dir};
index index.html;
}
EOF
service nginx restart
if ! command -v /root/.acme.sh/acme.sh >/dev/null 2>&1; then
wget -O - https://get.acme.sh | sh
judge "安装 Acme"
else
ok "Acme 已安装"
fi
cd ~ && . .bashrc
/root/.acme.sh/acme.sh --upgrade --auto-upgrade
/root/.acme.sh/acme.sh --set-default-ca --server letsencrypt
echo ${domain}
if /root/.acme.sh/acme.sh --issue -d ${domain} -w ${web_path}/${web_dir} --keylength ec-256 --force ${ipv6}; then
ok "SSL 证书生成成功"
sleep 2
mkdir -p ${ca_path}
if /root/.acme.sh/acme.sh --install-cert -d ${domain} --ecc --fullchain-file ${ca_crt} --key-file ${ca_key}; then
chmod +r ${ca_key}
ok "SSL 证书配置成功"
sleep 2
fi
else
error "证书生成失败"
exit 1
fi
}
flush_certificate() {
cat > ${ca_path}/xray-cert-renew.sh <<EOF
#!/bin/bash
git clone ${website_git} ${web_path}/${web_dir}
if /root/.acme.sh/acme.sh --issue -d ${domain} -w ${web_path}/${web_dir} --keylength ec-256 --force ${ipv6}; then
sleep 2
mkdir -p ${ca_path}
/root/.acme.sh/acme.sh --install-cert -d ${domain} --ecc --fullchain-file ${ca_crt} --key-file ${ca_key} --reloadcmd "nginx -s reload"
else
exit 1
fi
echo "Xray Certificates Renewed"
chmod +r ${ca_key}
echo "Read Permission Granted for Private Key"
systemctl restart xray
systemctl restart sing-box
echo "Xray Restarted"
EOF
chmod +x ${ca_path}/xray-cert-renew.sh
(
crontab -l | grep -v "bash ${ca_path}/xray-cert-renew.sh"
echo "0 7 1 */2 * bash ${ca_path}/xray-cert-renew.sh"
) | crontab -
}
xray_install() {
if ! command -v xray >/dev/null 2>&1; then
bash <(curl -fsSL $xray_install_url)
judge "Xray 安装"
else
ok "Xray 已安装"
fi
}
xray_configure() {
mkdir -p ${xray_log} && touch ${xray_log}/access.log && touch ${xray_log}/error.log && chmod a+w ${xray_log}/*.log
}
clash_config() {
case $protocol_type in
"hysteria2_nodomain")
clash_cfg=" - name: $domain
type: hysteria2
server: '$domain'
port: $port
up: 50 Mbps
down: 200 Mbps
password: $password
sni: https://live.qq.com
skip-cert-verify: true
alpn:
- h3"
;;
"hysteria2")
clash_cfg=" - name: $domain
type: hysteria2
server: '$domain'
port: $port
up: 50 Mbps
down: 200 Mbps
password: $password
alpn:
- h3"
;;
"reality_tcp")
clash_cfg=" - name: $ip
type: vless
server: '$ip'
port: $port
uuid: $password
network: tcp
tls: true
udp: true
flow: xtls-rprx-vision
servername: www.lovelive-anime.jp
reality-opts:
public-key: $public_key
short-id: 8eb7bab5a41eb27d
client-fingerprint: safari"
;;
"reality_grpc")
clash_cfg=" - name: $ip
type: vless
server: '$ip'
port: $port
uuid: $password
network: grpc
tls: true
udp: true
# skip-cert-verify: true
servername: www.lovelive-anime.jp
grpc-opts:
grpc-service-name: \"${ws_path}\"
reality-opts:
public-key: $public_key
short-id: 8eb7bab5a41eb27d
client-fingerprint: safari"
;;
"trojan_grpc")
clash_cfg=" - name: $domain
server: '$domain'
port: $port
type: trojan
password: $password
network: grpc
alpn:
- h2
sni: $domain
skip-cert-verify: false
udp: true
grpc-opts:
grpc-service-name: \"${ws_path}\""
;;
"trojan")
clash_cfg=" - name: $ip
type: trojan
server: '$ip'
port: $port
password: $password"
;;
"trojan_tcp")
clash_cfg=" - name: $domain
type: trojan
server: '$domain'
port: $port
password: $password
alpn:
- h2
- http/1.1"
;;
"vmess_ws")
clash_cfg=" - name: $domain
type: vmess
server: '$domain'
port: 443
uuid: $password
alterId: 0
cipher: auto
udp: true
tls: true
network: ws
ws-opts:
path: \"/${ws_path}\"
headers:
Host: $domain"
;;
"vless_ws")
clash_cfg=" - name: $domain
type: vless
server: '$domain'
port: 443
uuid: $password
udp: true
tls: true
network: ws
servername: $domain
# skip-cert-verify: true
ws-opts:
path: \"/${ws_path}\"
headers:
Host: $password"
;;
"vless_vison")
clash_cfg=" - name: $domain
type: vless
server: '$domain'
port: 443
uuid: $password
network: tcp
tls: true
udp: true
flow: xtls-rprx-vision
client-fingerprint: safari"
;;
"reality_h2")
clash_cfg=" - name: $ip
type: vless
server: '$ip'
port: $port
uuid: $password
tls: true
udp: true
network: h2
flow: ''
servername: www.lovelive-anime.jp
reality-opts:
public-key: $public_key
short-id: 8eb7bab5a41eb27d
client-fingerprint: safari"
;;
"shadowsocket")
clash_cfg=" - name: $domain
type: ss
server: '$domain'
port: $port
cipher: $ss_method
password: $password
udp: true"
;;
esac
}
qx_config() {
case $protocol_type in
"vmess_ws")
qx_cfg="vmess=$domain:443, method=chacha20-poly1305, password=$password, obfs=wss, obfs-host=$domain, obfs-uri=/${ws_path}, tls13=true, fast-open=false, udp-relay=false, tag=$domain"
;;
"trojan_tcp")
qx_cfg="trojan=$domain:443, password=$password, over-tls=true, tls-host=$domain, tls-verification=true, tls13=true, fast-open=false, udp-relay=false, tag=$domain"
;;
"trojan")
qx_cfg="trojan=$ip:$port, password=$password, tag=$ip"
;;
"shadowsocket")
qx_cfg="shadowsocks=$domain:$port, method=$ss_method, password=$password, tag=$domain"
;;
esac
}
xray_vless_reality_h2() {
password=$(xray uuid)
set_port
port_check $port
domain="www.lovelive-anime.jp"
protocol_type="reality_h2"
keys=$(xray x25519)
private_key=$(echo $keys | awk -F " " '{print $3}')
public_key=$(echo $keys | awk -F " " '{print $6}')
# short_id=$(openssl rand -hex 8)
ip=$(curl -sS --connect-timeout 4 ipinfo.io/ip)
ipv6=$(curl -sS6 --connect-timeout 4 ip.me)
wget -N ${xray_vless_reality_h2_url} -O ${xray_cfg}
judge "Xray Reality H2配置文件下载"
sed -i "s~\${password}~$password~" ${xray_cfg}
sed -i "s~\${privateKey}~$private_key~" ${xray_cfg}
sed -i "s~\${port}~$port~" ${xray_cfg}
routing_set
vless_reality_h2_outbound_config
systemctl restart xray
systemctl enable xray
link="vless://$password@$ip:$port?encryption=none&security=reality&sni=$domain&fp=safari&pbk=$public_key&type=http#$ip"
clash_config
}
xray_vless_reality_h2_append() {
password=$(xray uuid)
set_port
port_check $port
domain="www.lovelive-anime.jp"
protocol_type="reality_h2"
keys=$(xray x25519)
private_key=$(echo $keys | awk -F " " '{print $3}')
public_key=$(echo $keys | awk -F " " '{print $6}')
# short_id=$(openssl rand -hex 8)
ip=$(curl -sS --connect-timeout 4 ipinfo.io/ip)
cd /usr/local/etc/xray
wget -Nq ${vless_reality_h2_append_url} -O append.json
judge "Xray Reality H2配置文件下载"
sed -i "s~\${password}~$password~" append.json
sed -i "s~\${privateKey}~$private_key~" append.json
sed -i "s~\${port}~$port~" append.json
echo -e "$(xray run -confdir=./ -dump)" > config.json
rm append.json
vless_reality_h2_outbound_config
link="vless://$password@$ip:$port?encryption=none&security=reality&sni=$domain&fp=safari&pbk=$public_key&type=http#$ip"
clash_config
systemctl restart xray
}
xray_vless_reality_tcp() {
password=$(xray uuid)
set_port
port_check $port
domain="www.lovelive-anime.jp"
protocol_type="reality_tcp"
keys=$(xray x25519)
private_key=$(echo $keys | awk -F " " '{print $3}')
public_key=$(echo $keys | awk -F " " '{print $6}')
# short_id=$(openssl rand -hex 8)
ip=$(curl -sS --connect-timeout 4 ipinfo.io/ip)
ipv6=$(curl -sS6 --connect-timeout 4 ip.me)
wget -N ${xray_vless_reality_tcp_url} -O ${xray_cfg}
judge "Xray Reality 配置文件下载"
sed -i "s~\${password}~$password~" ${xray_cfg}
sed -i "s~\${privateKey}~$private_key~" ${xray_cfg}
sed -i "s~\${port}~$port~" ${xray_cfg}
routing_set
vless_reality_tcp_outbound_config
systemctl restart xray
systemctl enable xray
service nginx stop
link="vless://$password@$ip:$port?encryption=none&flow=xtls-rprx-vision&security=reality&sni=$domain&fp=safari&pbk=$public_key&type=tcp&headerType=none#$ip"
clash_config
}
xray_vless_reality_tcp_append() {
password=$(xray uuid)
set_port
port_check $port
domain="www.lovelive-anime.jp"
protocol_type="reality_tcp"
keys=$(xray x25519)
private_key=$(echo $keys | awk -F " " '{print $3}')
public_key=$(echo $keys | awk -F " " '{print $6}')
# short_id=$(openssl rand -hex 8)
ip=$(curl -sS --connect-timeout 4 ipinfo.io/ip)
cd /usr/local/etc/xray
wget -Nq ${xray_vless_reality_tcp_append_url} -O append.json
judge "Xray Reality 配置文件下载"
sed -i "s~\${password}~$password~" append.json
sed -i "s~\${privateKey}~$private_key~" append.json
sed -i "s~\${port}~$port~" append.json
echo -e "$(xray run -confdir=./ -dump)" > config.json
rm append.json
vless_reality_tcp_outbound_config
link="vless://$password@$ip:$port?encryption=none&flow=xtls-rprx-vision&security=reality&sni=$domain&fp=safari&pbk=$public_key&type=tcp&headerType=none#$ip"
clash_config
systemctl restart xray
}
xray_vless_reality_grpc() {
password=$(xray uuid)
set_port
port_check $port
protocol_type="reality_grpc"
keys=$(xray x25519)
private_key=$(echo $keys | awk -F " " '{print $3}')
public_key=$(echo $keys | awk -F " " '{print $6}')
# short_id=$(openssl rand -hex 8)
ip=$(curl -sS --connect-timeout 4 ipinfo.io/ip)
ipv6=$(curl -sS6 --connect-timeout 4 ip.me)
wget -N ${xray_vless_reality_grpc_url} -O ${xray_cfg}
judge "Xray Reality 配置文件下载"
sed -i "s~\${password}~$password~" ${xray_cfg}
sed -i "s~\${privateKey}~$private_key~" ${xray_cfg}
sed -i "s~\${ws_path}~$ws_path~" ${xray_cfg}
sed -i "s~\${port}~$port~" ${xray_cfg}
routing_set
vless_reality_grpc_outbound_config
systemctl restart xray
systemctl enable xray
clash_config
link="vless://$password@$ip:$port?encryption=none&security=reality&sni=$domain&sid=8eb7bab5a41eb27d&fp=safari&peer=$domain&allowInsecure=1&pbk=$public_key&type=grpc&serviceName=$ws_path&mode=multi#$ip"
}
xray_vless_reality_grpc_append() {
password=$(xray uuid)
set_port
port_check $port
domain="www.lovelive-anime.jp"
protocol_type="reality_grpc"
keys=$(xray x25519)
private_key=$(echo $keys | awk -F " " '{print $3}')
public_key=$(echo $keys | awk -F " " '{print $6}')
# short_id=$(openssl rand -hex 8)
ip=$(curl -sS ipinfo.io/ip)
cd /usr/local/etc/xray
wget -Nq ${xray_vless_reality_grpc_append_url} -O append.json
judge "Xray Reality 配置文件下载"
sed -i "s~\${password}~$password~" append.json
sed -i "s~\${privateKey}~$private_key~" append.json
sed -i "s~\${ws_path}~$ws_path~" append.json
sed -i "s~\${port}~$port~" append.json
echo -e "$(xray run -confdir=./ -dump)" > config.json
rm append.json
vless_reality_grpc_outbound_config
link="vless://$password@$ip:$port?encryption=none&security=reality&sni=$domain&sid=8eb7bab5a41eb27d&fp=safari&peer=$domain&allowInsecure=1&pbk=$public_key&type=grpc&serviceName=$ws_path&mode=multi#$ip"
clash_config
systemctl restart xray
}
trojan_grpc() {
port_check 80
port_check 443
nginx_install
domain_handle
apply_certificate
flush_certificate
protocol_type="trojan_grpc"
password=$(xray uuid)
port=443
wget -N ${xray_trojan_grpc_config_url} -O ${xray_cfg}
judge "配置文件下载"
sed -i "s~\${password}~$password~" ${xray_cfg}
sed -i "s~\${ws_path}~$ws_path~" ${xray_cfg}
routing_set
systemctl restart xray
systemctl enable xray
sleep 3
wget -N ${trojan_grpc_nginx_url} -O ${nginx_cfg}
judge "配置文件下载"
sed -i "s~\${domain}~$domain~" ${nginx_cfg}
sed -i "s~\${web_path}~$web_path~" ${nginx_cfg}
sed -i "s~\${web_dir}~$web_dir~" ${nginx_cfg}
sed -i "s~\${ca_crt}~$ca_crt~" ${nginx_cfg}
sed -i "s~\${ca_key}~$ca_key~" ${nginx_cfg}
sed -i "s~\${ws_path}~$ca_key~" ${nginx_cfg}
service nginx restart
link="trojan://${password}@${domain}:${port}?security=tls&type=grpc&serviceName=${ws_path}&mode=gun#${domain}"
clash_config
}
xray_trojan_tcp_tls() {
port_check 80
port_check 443
nginx_install
domain_handle
apply_certificate
flush_certificate
protocol_type="trojan_tcp"
password=$(xray uuid)
set_port
wget -N ${xray_trojan_tcp_tls_config_url} -O ${xray_cfg}
judge "配置文件下载"
sed -i "s~${port}~$port~" ${xray_cfg}
sed -i "s~\${password}~$password~" ${xray_cfg}
sed -i "s~\${ca_crt}~$ca_crt~" ${xray_cfg}
sed -i "s~\${ca_key}~$ca_key~" ${xray_cfg}
routing_set
trojan_tcp_tls_outbound_config
systemctl restart xray
systemctl enable xray
sleep 3
wget -N ${trojan_tcp_tls_nginx_url} -O ${nginx_cfg}
judge "配置文件下载"
sed -i "s~\${domain}~$domain~" ${nginx_cfg}
sed -i "s~\${web_path}~$web_path~" ${nginx_cfg}
sed -i "s~\${web_dir}~$web_dir~" ${nginx_cfg}
service nginx restart
link="trojan://${password}@${domain}:${port}?security=tls&type=tcp&headerType=none#${domain}"
clash_config
qx_config
}
xray_vmess_ws_tls() {
port_check 80
port_check 443
nginx_install
domain_handle
apply_certificate
flush_certificate
protocol_type="vmess_ws"
password=$(xray uuid)
wget -N ${xray_vmess_ws_config_url} -O ${xray_cfg}
judge "配置文件下载"
sed -i "s~19191~$port~" ${xray_cfg}
sed -i "s~\${password}~$password~" ${xray_cfg}
sed -i "s~\${ws_path}~$ws_path~" ${xray_cfg}
routing_set
systemctl restart xray
systemctl enable xray
sleep 3
wget -N ${vmess_ws_nginx_url} -O ${nginx_cfg}
judge "配置文件下载"
sed -i "s~\${domain}~$domain~" ${nginx_cfg}
sed -i "s~\${web_path}~$web_path~" ${nginx_cfg}
sed -i "s~\${web_dir}~$web_dir~" ${nginx_cfg}
sed -i "s~\${ca_crt}~$ca_crt~" ${nginx_cfg}
sed -i "s~\${ca_key}~$ca_key~" ${nginx_cfg}
sed -i "s~\${ws_path}~$ws_path~" ${nginx_cfg}
sed -i "s~\${port}~$port~" ${nginx_cfg}
service nginx restart
tmp="{\"v\":\"2\",\"ps\":\"${domain}\",\"add\":\"${domain}\",\"port\":\"443\",\"id\":\"${password}\",\"aid\":\"0\",\"scy\":\"auto\",\"net\":\"ws\",\"type\":\"none\",\"host\":\"${domain}\",\"path\":\"/${ws_path}\",\"tls\":\"tls\",\"sni\":\"${domain}\",\"alpn\":\"\",\"fp\":\"safari\"}"
encode_link=$(openssl base64 <<< $tmp)
link="vmess://$encode_link"
clash_config
qx_config
vmess_ws_tls_outbound_config
}
vless_ws_tls() {
port_check 80
port_check 443
nginx_install
domain_handle
apply_certificate
flush_certificate
protocol_type="vless_ws"
password=$(xray uuid)
wget -N ${vless_ws_config_url} -O ${xray_cfg}
judge "配置文件下载"
sed -i "s~\${ws_path}~$ws_path~" ${xray_cfg}
sed -i "s~\${password}~$password~" ${xray_cfg}
routing_set
systemctl restart xray && systemctl enable xray
sleep 3
wget -N ${vless_ws_nginx_url} -O ${nginx_cfg}
judge "配置文件下载"
sed -i "s~\${domain}~$domain~" ${nginx_cfg}
sed -i "s~\${web_path}~$web_path~" ${nginx_cfg}
sed -i "s~\${web_dir}~$web_dir~" ${nginx_cfg}
sed -i "s~\${ca_crt}~$ca_crt~" ${nginx_cfg}
sed -i "s~\${ca_key}~$ca_key~" ${nginx_cfg}
sed -i "s~\${ws_path}~$ws_path~" ${nginx_cfg}
service nginx restart
parts="auto:${password}@${domain}:443"
encode_parts=$(openssl base64 <<< $parts)
link="vless://${encode_parts}?encryption=none&security=tls&sni=${domain}&type=ws&host=${domain}&path=%2F${ws_path}#${domain}"
clash_config
}
vless_grpc() {
port_check 80
port_check 443
nginx_install
domain_handle
apply_certificate
flush_certificate
protocol_type="vless_grpc"
password=$(xray uuid)
wget -N ${vless_grpc_config_url} -O ${xray_cfg}
judge "配置文件下载"
sed -i "s~\${password}~$password~" ${xray_cfg}
sed -i "s~\${ws_path}~$ws_path~" ${xray_cfg}
routing_set
systemctl restart xray && systemctl enable xray
sleep 3
wget -N ${vless_grpc_nginx_url} -O ${nginx_cfg}
judge "配置文件下载"
sed -i "s~\${domain}~$domain~" ${nginx_cfg}
sed -i "s~\${web_path}~$web_path~" ${nginx_cfg}
sed -i "s~\${ws_path}~$ws_path~" ${nginx_cfg}
sed -i "s~\${ws_path}~$ws_path~" ${nginx_cfg}
sed -i "s~\${web_dir}~$web_dir~" ${nginx_cfg}
sed -i "s~\${ca_crt}~$ca_crt~" ${nginx_cfg}
sed -i "s~\${ca_key}~$ca_key~" ${nginx_cfg}
service nginx restart
parts="auto:${password}@${domain}:443"
encode_parts=$(openssl base64 <<< $parts)
link="vless://${encode_parts}?encryption=none&security=tls&sni=${domain}&type=grpc&host=${domain}&path=%2F${ws_path}#${domain}"
}
vless_tcp_xtls_vision() {
port_check 80
port_check 443
nginx_install
domain_handle
apply_certificate
flush_certificate
protocol_type="vless_vison"
password=$(xray uuid)
vless_tcp_xtls_vision_xray_cfg
systemctl restart xray && systemctl enable xray
sleep 3
vless_tcp_xtls_vision_nginx_cfg
service nginx restart
parts="auto:${password}@${domain}:443"
encode_parts=$(openssl base64 <<< $parts)
link="vless://${encode_parts}?encryption=none&flow=xtls-rprx-vision&security=tls&type=tcp&headerType=none#${domain}"
clash_config
}
vless_tcp_xtls_vision_nginx_cfg() {
cd /etc/nginx/ && wget -N ${vless_vision_nginx_url} -O /etc/nginx/nginx.conf
judge "配置文件下载"
}
vless_tcp_xtls_vision_xray_cfg() {
wget -N ${vless_vision_config_url} -O config.json
judge "配置文件下载"
sed -i "s/\${password}/$password/" config.json
sed -i "s~\${ca_crt}~$ca_crt~" config.json
sed -i "s~\${ca_key}~$ca_key~" config.json
routing_set
mv config.json ${xray_cfg}
}
xray_trojan() {
protocol_type="trojan"
ip=`curl -sS ipinfo.io/ip`
info "trojan基础不需要Nginx, 可以通过脚本一键卸载"
close_nginx()
if ! command -v openssl >/dev/null 2>&1; then
${INS} openssl
judge "openssl 安装"
fi
set_port
password=$(openssl rand -base64 16)
wget -N ${xray_trojan_config_url} -O config.json
judge "配置文件下载"
sed -i "s~\${port}~$port~" config.json
sed -i "s~\${password}~$password~" config.json
mv config.json ${xray_cfg}
systemctl restart xray && systemctl enable xray
link="trojan://${password}@${ip}:${port}#${domain}"
trojan_outbound_config
clash_config
qx_config
}