-
Notifications
You must be signed in to change notification settings - Fork 16
/
install.sh
2127 lines (2030 loc) · 54.7 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#colors
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
purple='\033[0;35m'
cyan='\033[0;36m'
rest='\033[0m'
#progress bar
display_progress() {
local duration=$1
local sleep_interval=0.1
local progress=0
local bar_length=40
local colors=("[41m" "[42m" "[43m" "[44m" "[45m" "[46m" "[47m")
while [ "$progress" -lt "$duration" ]; do
echo -ne "\r${colors[$((progress % 7))]}"
for ((i = 0; i < bar_length; i++)); do
if [ $i -lt $((progress * bar_length / duration)) ]; then
echo -ne "█"
else
echo -ne "░"
fi
done
echo -ne "[0m ${progress}%"
progress=$((progress + 1))
sleep $sleep_interval
done
echo -ne "\r${colors[0]}"
for ((i = 0; i < bar_length; i++)); do
echo -ne " "
done
echo -ne "[0m 100%"
echo
}
#detect_distribution
detect_distribution() {
if [ -f /etc/os-release ]; then
source /etc/os-release
case "${ID}" in
ubuntu | debian)
p_m="apt"
;;
centos)
p_m="yum"
;;
fedora)
p_m="dnf"
;;
*)
echo "Unsupported distribution!"
exit 1
;;
esac
echo "${ID}"
"${p_m}" update -y
else
echo "Unsupported distribution!"
exit 1
fi
}
#realip
realip() {
ip=$(curl -s4m8 ip.sb -k) || ip=$(curl -s6m8 ip.sb -k)
}
#check_and_close_port
check_and_close_port() {
local port=80
if lsof -Pi ":$port" -sTCP:LISTEN -t >/dev/null 2>&1; then
echo "Port $port is in use. Closing the port..."
fuser -k "$port/tcp"
fi
}
ip=$(hostname -I | awk '{print $1}')
#check_dependencies
check_dependencies() {
detect_distribution
local dependencies=("curl" "wget" "dnsutils" "openssl" "socat" "coreutils" "jq" "lsof" "qrencode")
for dep in "${dependencies[@]}"; do
if ! dpkg -s "${dep}" &>/dev/null; then
echo "${dep} is not installed. Installing..."
sudo "${p_m}" install "${dep}" -y
fi
done
}
download_cf() {
# Check if the file already exists
if [ -x /etc/s-box/cloudflared ]; then
echo "cf is already installed."
return 0
fi
[ ! -d "/etc/s-box" ] && mkdir /etc/s-box
[ ! -d "/root/peyman/configs" ] && mkdir -p /root/peyman/configs
# Check the operating system type
if [[ "$(uname -m)" == "x86_64" ]]; then
download_url="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64"
elif [[ "$(uname -m)" == "aarch64" ]]; then
download_url="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64"
elif [[ "$(uname -m)" == "armv7l" ]]; then
download_url="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm"
elif [[ "$(uname -m)" == "i686" ]]; then
download_url="https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-386"
else
echo "Unsupported operating system."
return 1
fi
# Download and install if the file doesn't exist
sudo wget -O /etc/s-box/cloudflared $download_url >/dev/null 2>&1
sudo chmod +x /etc/s-box/cloudflared
}
#install certificates
install_certs() {
echo ""
echo -e "${cyan}Methods of applying certificate :${rest}"
echo -e "${green}1.${rest}Bing self-signed certificate ${yellow} (default) ${rest}"
echo -e "${green}2.${rest}Acme (Domain Required)${rest}"
echo ""
read -rp "Please enter options [1-2]: " certInput
if [[ $certInput == 2 ]]; then
tf="true"
if [[ -f /root/peyman/cert.crt && -f /root/peyman/private.key ]] && [[ -s /root/peyman/cert.crt && -s /root/peyman/private.key ]] && [[ -f /root/peyman/ca.log ]]; then
domain=$(cat /root/peyman/ca.log)
echo -e "${green}The certificate of the original domain name: $domain was detected and is being applied${rest}"
hy_domain=$domain
else
WARPv4Status=$(curl -s4m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
WARPv6Status=$(curl -s6m8 https://www.cloudflare.com/cdn-cgi/trace -k | grep warp | cut -d= -f2)
if [[ $WARPv4Status =~ on|plus ]] || [[ $WARPv6Status =~ on|plus ]]; then
wg-quick down wgcf >/dev/null 2>&1
systemctl stop warp-go >/dev/null 2>&1
realip
wg-quick up wgcf >/dev/null 2>&1
systemctl start warp-go >/dev/null 2>&1
else
realip
fi
read -p "Please enter the domain name: " domain
[[ -z $domain ]] && red "No domain name entered, unable to perform operation!" && exit 1
echo -e "${green}Domain name entered: $domain${rest}" && sleep 1
check_and_close_port
domainIP=$(dig +short "${domain}")
if [[ $domainIP == "$ip" ]]; then
if [[ $ID == "CentOS" ]]; then
$p_m install cronie -y
systemctl start crond
systemctl enable crond
else
$p_m install cron -y
systemctl start cron
systemctl enable cron
fi
curl https://get.acme.sh | sh -s "email=$(date +%s%N | md5sum | cut -c 1-16)@gmail.com"
source ~/.bashrc
bash ~/.acme.sh/acme.sh --upgrade --auto-upgrade
bash ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt
if echo "$ip" | grep -q ":"; then
bash ~/.acme.sh/acme.sh --issue -d "${domain}" --standalone -k ec-256 --listen-v6 --insecure
else
bash ~/.acme.sh/acme.sh --issue -d "${domain}" --standalone -k ec-256 --insecure
fi
bash ~/.acme.sh/acme.sh --install-cert -d "${domain}" --key-file /root/peyman/private.key --fullchain-file /root/peyman/cert.crt --ecc
if [[ -f /root/peyman/cert.crt && -f /root/peyman/private.key ]] && [[ -s /root/peyman/cert.crt && -s /root/peyman/private.key ]]; then
echo "$domain" >/root/peyman/ca.log
sed -i '/--cron/d' /etc/crontab >/dev/null 2>&1
echo "0 0 * * * root bash /root/.acme.sh/acme.sh --cron -f >/dev/null 2>&1" >>/etc/crontab
echo -e "${green}Successful! The certificate (cer.crt) and private key (private.key) saved in /root${rest}"
echo -e "${green}The certificate crt file path: /root/peyman/cert.crt${rest}"
echo -e "${green}The private key file path: /root/peyman/private.key${rest}"
chmod 777 /root/peyman/cert.crt
chmod 777 /root/peyman/private.key
chmod 777 /root/peyman/ca.log
hy_domain=$domain
read -rp "Do you want to use a subdomain with CDN [ON] for configs with TLS? Enter a subdomain or Press Enter to skip :" subdomain
if [[ -n $subdomain ]]; then
domain_cdn=$subdomain
echo -e "${green}Sub domain name entered: $domain_cdn${rest}" && sleep 1
else
domain_cdn=$domain
fi
fi
else
echo -e "${red}The IP resolved by the current domain name does not match the real IP used by the current VPS${rest}"
echo -e "${green}uggestions below :${rest}"
echo -e "${yellow}1. Please make sure that CloudFlare is turned off (DNS only). The same applies to other domain name resolution or CDN website settings.${rest}"
echo -e "${yellow}2. Please check whether the IP set by DNS resolution is the real IP of the VPS${rest}"
exit 1
fi
fi
else
echo -e "${green}You selected Bing self-signed certificate.${rest}"
[ ! -d "/root/peyman/configs" ] && mkdir -p /root/peyman/configs
openssl ecparam -genkey -name prime256v1 -out /root/peyman/private.key
openssl req -new -x509 -days 36500 -key /root/peyman/private.key -out /root/peyman/cert.crt -subj "/CN=www.bing.com"
chmod 777 /root/peyman/cert.crt
chmod 777 /root/peyman/private.key
hy_domain="www.bing.com"
domain="$ip"
tf="false"
fi
}
#download sing-box
download-sb() {
if [ "$ID" == "ubuntu" ]; then
bash <(curl -fsSL https://sing-box.app/deb-install.sh)
elif [ "$ID" == "debian" ]; then
bash <(curl -fsSL https://sing-box.app/deb-install.sh)
elif [ "$ID" == "centos" ] || [ "$ID" == "redhat" ]; then
bash <(curl -fsSL https://sing-box.app/rpm-install.sh)
elif [ "$ID" == "arch" ]; then
bash <(curl -fsSL https://sing-box.app/arch-install.sh)
else
echo "Unsupported distribution!"
exit 1
fi
}
install() {
if systemctl is-active --quiet s-box.service; then
echo "sing-box is already installed."
exit 1
else
echo "Installing..."
fi
check_dependencies
download_cf
download-sb
install_certs
uuid=$(sing-box generate uuid)
keys=$(sing-box generate reality-keypair)
private_key=$(echo $keys | awk -F " " '{print $2}')
public_key=$(echo $keys | awk -F " " '{print $4}')
short_id=$(openssl rand -hex 8)
read -p "Do you want to use random Ports? [y/n]: " randomPort
randomPort=${randomPort:-"y"}
if [ "$randomPort" == "y" ]; then
vlessport=$(shuf -i 2000-65535 -n 1)
vlessgport=${vlessgport:-2083}
vmessport=${vmessport:-2053}
hyport=$(shuf -i 2000-65535 -n 1)
tuicport=$(shuf -i 2000-65535 -n 1)
else
read -p "Enter VLESS port [default: 2087]: " vlessport
vlessport=${vlessport:-2087}
while lsof -Pi :$vlessport -sTCP:LISTEN -t >/dev/null; do
echo -e "${red}Error: Port $vlessport is already in use.${rest}"
read -p "Enter a different VLESS port: " vlessport
vlessport=${vlessport:-2087}
done
read -p "Enter VLESS_GRPC port [default: 2083]: " vlessgport
vlessgport=${vlessgport:-2083}
while lsof -Pi :$vlessgport -sTCP:LISTEN -t >/dev/null; do
echo -e "${red}Error: Port $vlessgport is already in use.${rest}"
read -p "Enter a different VLESS port: " vlessgport
vlessgport=${vlessgport:-2083}
done
read -p "Enter VMESS port [default: 2053]: " vmessport
vmessport=${vmessport:-2053}
while lsof -Pi :$vmessport -sTCP:LISTEN -t >/dev/null; do
echo -e "${red}Error: Port $vmessport is already in use.${rest}"
read -p "Enter a different VMESS port: " vmessport
vmessport=${vmessport:-2053}
done
read -p "Enter HYSTERIA port [default: 2096]: " hyport
hyport=${hyport:-2096}
while lsof -Pi :$hyport -sTCP:LISTEN -t >/dev/null; do
echo -e "${red}Error: Port $hyport is already in use.${rest}"
read -p "Enter a different HYSTERIA port: " hyport
hyport=${hyport:-2096}
done
read -p "Enter TUIC port [default: 8443]: " tuicport
tuicport=${tuicport:-8443}
while lsof -Pi :$tuicport -sTCP:LISTEN -t >/dev/null; do
echo -e "${red}Error: Port $tuicport is already in use.${rest}"
read -p "Enter a different TUIC port: " tuicport
tuicport=${tuicport:-8443}
done
fi
server_config
(
crontab -l
echo "0 1 * * * systemctl restart sing-box >/dev/null 2>&1"
) | sort - | uniq - | crontab -
if [[ $certInput == 2 ]]; then
config-sing-box
config-nekobox
telegram_tls
setup_service
config_tls
else
setup_service
telegram_ip
fi
}
server_config() {
cat <<EOL >/etc/s-box/sb.json
{
"log": {
"disabled": false,
"level": "info",
"timestamp": true
},
"inbounds": [
{
"type": "vless",
"tag": "vless-tcp-reality",
"sniff": true,
"sniff_override_destination": true,
"listen": "::",
"listen_port": $vlessport,
"users": [
{
"uuid": "$uuid",
"flow": "xtls-rprx-vision"
}
],
"tls": {
"enabled": true,
"server_name": "www.yahoo.com",
"reality": {
"enabled": true,
"handshake": {
"server": "www.yahoo.com",
"server_port": 443
},
"private_key": "$private_key",
"short_id": ["$short_id"]
}
}
},
{
"type": "vmess",
"tag": "vmess-sb",
"sniff": true,
"sniff_override_destination": true,
"listen": "::",
"listen_port": $vmessport,
"users": [
{
"uuid": "$uuid",
"alterId": 0
}
],
"transport": {
"type": "ws",
"path": "$uuid"
},
"tls":{
"enabled": $tf,
"server_name": "$domain_cdn",
"min_version": "1.2",
"max_version": "1.3",
"certificate_path": "/root/peyman/cert.crt",
"key_path": "/root/peyman/private.key"
}
},
{
"type": "vless",
"tag": "vless-grpc",
"sniff": true,
"sniff_override_destination": true,
"listen": "::",
"listen_port": $vlessgport,
"users": [
{
"uuid": "$uuid"
}
],
"transport": {
"type": "grpc",
"service_name": "$domain_cdn"
},
"tls":{
"enabled": true,
"server_name": "$domain_cdn",
"min_version": "1.2",
"max_version": "1.3",
"certificate_path": "/root/peyman/cert.crt",
"key_path": "/root/peyman/private.key"
}
},
{
"type": "hysteria2",
"tag": "hy2-sb",
"sniff": true,
"sniff_override_destination": true,
"listen": "::",
"listen_port": $hyport,
"obfs": {
"type": "salamander",
"password": "$uuid"
},
"users": [
{
"password": "$uuid"
}
],
"ignore_client_bandwidth":false,
"tls": {
"enabled": true,
"alpn": [
"h3"
],
"enabled": true,
"server_name": "www.google.com",
"certificate_path": "/root/peyman/cert.crt",
"key_path": "/root/peyman/private.key"
}
},
{
"type":"tuic",
"tag": "tuic5-sb",
"sniff": true,
"sniff_override_destination": true,
"listen": "::",
"listen_port": $tuicport,
"users": [
{
"uuid": "$uuid",
"password": "$uuid"
}
],
"congestion_control": "bbr",
"tls":{
"enabled": true,
"alpn": [
"h3"
],
"certificate_path": "/root/peyman/cert.crt",
"key_path": "/root/peyman/private.key"
}
}
],
"outbounds": [
{
"type":"direct",
"tag":"direct",
"domain_strategy": "prefer_ipv4"
},
{
"type":"direct",
"tag": "vps-outbound-v4",
"domain_strategy":"ipv4_only"
},
{
"type":"direct",
"tag": "vps-outbound-v6",
"domain_strategy":"ipv6_only"
},
{
"type": "socks",
"tag": "socks-out",
"server": "127.0.0.1",
"server_port": 40000,
"version": "5"
},
{
"type":"direct",
"tag":"socks-IPv4-out",
"detour":"socks-out",
"domain_strategy":"ipv4_only"
},
{
"type":"direct",
"tag":"socks-IPv6-out",
"detour":"socks-out",
"domain_strategy":"ipv6_only"
},
{
"type":"direct",
"tag":"warp-IPv4-out",
"detour":"wireguard-out",
"domain_strategy":"ipv4_only"
},
{
"type":"direct",
"tag":"warp-IPv6-out",
"detour":"wireguard-out",
"domain_strategy":"ipv6_only"
},
{
"type":"wireguard",
"tag":"wireguard-out",
"server":"162.159.193.10",
"server_port":1701,
"local_address":[
"172.16.0.2/32",
"2606:4700:110:891c:6ee2:7df4:5e99:b7cf/128"
],
"private_key":"aJkrp4MMgL/Oi2bO4Fww9J8aqAW1ojeOZ22RK0nXYWY=",
"peer_public_key":"bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=",
"reserved":[230,25,169]
},
{
"type": "block",
"tag": "block"
}
],
"route":{
"geoip":{
"download_url":"https://github.com/Ptechgithub/sing-box/blob/main/geo/geoip.db",
"download_detour":"direct"
},
"geosite":{
"download_url":"https://github.com/Ptechgithub/sing-box/blob/main/geo/geosite.db",
"download_detour":"direct"
},
"rules":[
{
"protocol": ["quic"],
"port": [ 443 ],
"outbound": "block"
},
{
"outbound": "direct",
"network": "udp,tcp"
}
]
}
}
EOL
}
setup_service() {
cat <<EOL >"/etc/systemd/system/s-box.service"
[Unit]
After=network.target nss-lookup.target
[Service]
User=root
WorkingDirectory=/usr/bin
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
ExecStart=/usr/bin/sing-box run -c /etc/s-box/sb.json
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=10
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
EOL
sudo systemctl daemon-reload
sudo systemctl start s-box.service
sudo systemctl enable s-box.service
}
telegram_ip() {
echo -e "${cyan}Do you want to receive the configs through Telegram bot? (y/n)${rest} \c"
read configure_via_telegram
if [[ "$configure_via_telegram" == "y" ]]; then
echo -e "Enter your ${yellow}Telegram bot Token${rest} :\c"
read token
echo -e "Enter Your ${yellow}chat ID${rest}.${purple}(Get your Chat ID in: bot--> @userinfobot) ${rest}: \c"
read chat_id
display_progress 20
echo "Please wait about 20s for connecting Argo tunnel..."
config_ip
message="🖐سلام، کانفیگ های شما با موفقیت ساخته شد.
1⃣
$(config_ip | grep -o 'tuic://.*#peyman-tuic5')
2⃣
$(config_ip | grep -o 'hysteria2://.*#peyman-hy2')
3⃣
$(config_ip | grep -o 'vless://.*#peyman-vless-reality')
4⃣
$(config_ip | grep -o 'vmess://.*' | head -n 1)
5️⃣
$(config_ip | grep -o 'vmess://.*' | tail -n 1)"
response=$(curl -s "https://api.telegram.org/bot$token/sendMessage" \
--data-urlencode "chat_id=$chat_id" \
--data-urlencode "text=$message")
json_file="/root/peyman/configs/config-nekobox.json"
caption="📦 این فایل ترکیب کانفیگ با هم است. لطفا روی نرم افزار Nekobox اجرا شود."
curl -s -X POST \
https://api.telegram.org/bot$token/sendDocument \
-F document=@$json_file \
-F chat_id=$chat_id \
-F caption="$caption" >/dev/null
json_files="/root/peyman/configs/config-sing-box.json"
captions="📦 این فایل ترکیب کانفیگ با هم است. لطفا روی نرم افزار Sing-Box اجرا شود."
curl -s -X POST \
https://api.telegram.org/bot$token/sendDocument \
-F document=@$json_files \
-F chat_id=$chat_id \
-F caption="$captions" >/dev/null
if [[ "$(echo "$response" | jq -r '.ok')" == "true" ]]; then
echo -e "${green}Message sent to telegram successfully!${rest}"
else
echo -e "${red}Failed to send message. Check your bot token and chat ID.${rest}"
fi
else
display_progress 10
echo "Please Wait..."
config_ip
fi
}
config_ip() {
nohup /etc/s-box/cloudflared tunnel --url http://localhost:$(jq -r .inbounds[1].listen_port /etc/s-box/sb.json) --edge-ip-version auto --no-autoupdate --protocol http2 >/etc/s-box/argo.log 2>&1 &
max_wait_seconds=10
seconds_waited=0
while [ $seconds_waited -lt $max_wait_seconds ]; do
if [ -f /etc/s-box/argo.log ] && grep -q 'https://.*trycloudflare.com' /etc/s-box/argo.log; then
break
fi
sleep 1
((seconds_waited++))
done
if [ $seconds_waited -ge $max_wait_seconds ]; then
echo "Argo Can't run."
echo ""
echo -e "${purple}--------------------These are your configs.----------------------${rest}"
echo ""
tuic="tuic://$uuid:$uuid@$ip:$tuicport?congestion_control=bbr&udp_relay_mode=native&alpn=h3&sni=www.bing.com&allow_insecure=1#peyman-tuic5"
echo "$tuic"
echo ""
echo -e "${purple}---------------------------------TUIC5-------------------------------${rest}"
echo "$tuic" | qrencode -t ANSIUTF8
echo "$tuic" >"/root/peyman/configs/tuic_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
hysteria2="hysteria2://$uuid@$ip:$hyport?insecure=1&mport=$hyport&sni=www.bing.com&obfs=salamander&obfs-password=$uuid#peyman-hy2"
echo "$hysteria2"
echo ""
echo -e "${purple}-------------------------------HYSTERIA2-----------------------------${rest}"
echo "$hysteria2" | qrencode -t ANSIUTF8
echo "$hysteria2" >"/root/peyman/configs/hysteria2_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
vless="vless://$uuid@$ip:$vlessport?encryption=none&flow=xtls-rprx-vision&security=reality&sni=www.yahoo.com&fp=chrome&pbk=$public_key&sid=$short_id&type=tcp&headerType=none#peyman-vless-reality"
echo "$vless"
echo ""
echo -e "${purple}----------------------------VlESS-TCP-REALITY------------------------${rest}"
echo "$vless" | qrencode -t ANSIUTF8
echo "$vless" >"/root/peyman/configs/vless_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
vmess="{\"add\":\"$ip\",\"aid\":\"0\",\"host\":\"www.bing.com\",\"id\":\"$uuid\",\"net\":\"ws\",\"path\":\"$uuid\",\"port\":\"$vmessport\",\"ps\":\"peyman-ws\",\"tls\":\"\",\"type\":\"none\",\"v\":\"2\"}"
encoded_vmess=$(echo -n "$vmess" | base64 -w 0)
echo "vmess://$encoded_vmess"
echo ""
echo -e "${purple}--------------------------------VMESS-WS----------------------------${rest}"
echo "$vmess://$encoded_vmess" | qrencode -t ANSIUTF8
echo "vmess://$encoded_vmess" >"/root/peyman/configs/vmess_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
else
link=$(grep -o 'https://.*trycloudflare.com' /etc/s-box/argo.log | sed 's/https:\/\///')
config-sing-boxx
config-nekoboxx
echo ""
echo -e "${purple}--------------------These are your configs.----------------------${rest}"
echo ""
tuic="tuic://$uuid:$uuid@$ip:$tuicport?congestion_control=bbr&udp_relay_mode=native&alpn=h3&sni=www.bing.com&allow_insecure=1#peyman-tuic5"
echo "$tuic"
echo ""
echo -e "${purple}---------------------------------TUIC5-------------------------------${rest}"
echo "$tuic" | qrencode -t ANSIUTF8
echo "$tuic" >"/root/peyman/configs/tuic_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
hysteria2="hysteria2://$uuid@$ip:$hyport?insecure=1&mport=$hyport&sni=www.bing.com&obfs=salamander&obfs-password=$uuid#peyman-hy2"
echo "$hysteria2"
echo ""
echo -e "${purple}-------------------------------HYSTERIA2-----------------------------${rest}"
echo "$hysteria2" | qrencode -t ANSIUTF8
echo "$hysteria2" >"/root/peyman/configs/hysteria2_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
vless="vless://$uuid@$ip:$vlessport?encryption=none&flow=xtls-rprx-vision&security=reality&sni=www.yahoo.com&fp=chrome&pbk=$public_key&sid=$short_id&type=tcp&headerType=none#peyman-vless-reality"
echo "$vless"
echo ""
echo -e "${purple}----------------------------VlESS-TCP-REALITY------------------------${rest}"
echo "$vless" | qrencode -t ANSIUTF8
echo "$vless" >"/root/peyman/configs/vless_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
vmess="{\"add\":\"$ip\",\"aid\":\"0\",\"host\":\"www.bing.com\",\"id\":\"$uuid\",\"net\":\"ws\",\"path\":\"$uuid\",\"port\":\"$vmessport\",\"ps\":\"peyman-ws\",\"tls\":\"\",\"type\":\"none\",\"v\":\"2\"}"
encoded_vmess=$(echo -n "$vmess" | base64 -w 0)
echo "vmess://$encoded_vmess"
echo ""
echo -e "${purple}----------------------------------VMESS-WS------------------------------${rest}"
echo "$vmess://$encoded_vmess" | qrencode -t ANSIUTF8
echo "vmess://$encoded_vmess" >"/root/peyman/configs/vmess_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
vmess="{\"add\":\"104.31.16.60\",\"aid\":\"0\",\"host\":\"$link\",\"id\":\"$uuid\",\"net\":\"ws\",\"path\":\"$uuid\",\"port\":\"443\",\"ps\":\"peyman-vmess-Argo\",\"tls\":\"tls\",\"sni\":\"$link\",\"type\":\"none\",\"v\":\"2\"}"
encoded_vmess=$(echo -n "$vmess" | base64 -w 0)
echo "vmess://$encoded_vmess"
echo ""
echo -e "${purple}-------------------------VMESS-WS-TLS+ARGO-TUNNEL------------------${rest}"
echo "$vmess://$encoded_vmess" | qrencode -t ANSIUTF8
echo "vmess://$encoded_vmess" >"/root/peyman/configs/vmess_Argo_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
(crontab -l 2>/dev/null | grep -q -F "@reboot /bin/bash -c \"/etc/s-box/cloudflared tunnel --url http://localhost:$(jq -r .inbounds[1].listen_port /etc/s-box/sb.json) --edge-ip-version auto --no-autoupdate --protocol http2 > /etc/s-box/argo.log 2>&1\"") || (
crontab -l 2>/dev/null
echo "@reboot /bin/bash -c \"/etc/s-box/cloudflared tunnel --url http://localhost:$(jq -r .inbounds[1].listen_port /etc/s-box/sb.json) --edge-ip-version auto --no-autoupdate --protocol http2 > /etc/s-box/argo.log 2>&1\""
) | crontab - >/dev/null 2>&1
fi
}
telegram_tls() {
echo -e "${cyan}Do you want to receive the configs through Telegram bot? (y/n)${rest} \c"
read configure_via_telegram
if [[ "$configure_via_telegram" == "y" ]]; then
echo -e "Enter your ${yellow}Telegram bot Token${rest} :\c"
read token
echo -e "Enter Your ${yellow}chat ID${rest}.${purple}(Get your Chat ID in: bot--> @userinfobot) ${rest}: \c"
read chat_id
display_progress 10
sleep 1
echo "Please Wait..."
message="🖐سلام، کانفیگ های شما با موفقیت ساخته شد.
1⃣
$(config_tls | grep -o 'tuic://.*#peyman-tuic5')
2⃣
$(config_tls | grep -o 'hysteria2://.*#peyman-hy2')
3⃣
$(config_tls | grep -o 'vless://.*#peyman-vless-reality')
4⃣
$(config_tls | grep -o 'vmess://.*')
5️⃣
$(config_tls | grep -o 'vless://.*' | tail -n 1)"
response=$(curl -s "https://api.telegram.org/bot$token/sendMessage" \
--data-urlencode "chat_id=$chat_id" \
--data-urlencode "text=$message")
file="/root/peyman/configs/config-nekobox.json"
caption="📦 این فایل ترکیب کانفیگ با هم است. لطفا روی نرم افزار Nekobox اجرا شود."
curl -s -X POST \
https://api.telegram.org/bot$token/sendDocument \
-F document=@$file \
-F chat_id=$chat_id \
-F caption="$caption" >/dev/null
files="/root/peyman/configs/config-sing-box.json"
captions="📦 این فایل ترکیب کانفیگ با هم است. لطفا روی نرم افزار Sing-Box اجرا شود."
curl -s -X POST \
https://api.telegram.org/bot$token/sendDocument \
-F document=@$files \
-F chat_id=$chat_id \
-F caption="$captions" >/dev/null
if [[ "$(echo "$response" | jq -r '.ok')" == "true" ]]; then
echo -e "${green}Message sent to telegram successfully!${rest}"
else
echo -e "${red}Failed to send message. Check your bot token and chat ID.${rest}"
fi
else
show_output=$(config_tls)
fi
}
config_tls() {
sleep 1
echo ""
echo -e "${purple}--------------------These are your configs.----------------------${rest}"
echo ""
echo -e "${purple}---------------------------------TUIC5-------------------------------${rest}"
tuic="tuic://$uuid:$uuid@$domain:$tuicport?congestion_control=bbr&udp_relay_mode=native&alpn=h3&sni=$domain&allow_insecure=0#peyman-tuic5"
echo "$tuic"
echo ""
echo "$tuic" | qrencode -t ANSIUTF8
echo "$tuic" >"/root/peyman/configs/tuic_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
hysteria2="hysteria2://$uuid@$domain:$hyport?insecure=0&mport=$hyport&sni=$domain&obfs=salamander&obfs-password=$uuid#peyman-hy2"
echo "$hysteria2"
echo ""
echo -e "${purple}-------------------------------HYSTERIA2-----------------------------${rest}"
echo "$hysteria2" | qrencode -t ANSIUTF8
echo "$hysteria2" >"/root/peyman/configs/hysteria2_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
vless="vless://$uuid@$domain:$vlessport?encryption=none&flow=xtls-rprx-vision&security=reality&sni=www.yahoo.com&fp=chrome&pbk=$public_key&sid=$short_id&type=tcp&headerType=none#peyman-vless-reality"
echo "$vless"
echo ""
echo -e "${purple}----------------------------VlESS-TCP-REALITY------------------------${rest}"
echo "$vless" | qrencode -t ANSIUTF8
echo "$vless" >"/root/peyman/configs/vless_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
vlessg="vless://$uuid@$domain_cdn:$vlessgport/?type=grpc&encryption=none&serviceName=$domain_cdn&security=tls&sni=$domain_cdn&alpn=h2&fp=chrome#peyman-Vless-GRPC-Tls"
echo "$vlessg"
echo ""
echo -e "${purple}---------------------------------VLESS-GRPC-TLS-----------------------------${rest}"
echo "$vlessg" | qrencode -t ANSIUTF8
echo "$vlessg" >"/root/peyman/configs/vless_grpc_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
vmess='{"add":"'$domain_cdn'","aid":"0","host":"'$domain_cdn'","id":"'$uuid'","net":"ws","path":"'$uuid'","port":"'$vmessport'","ps":"peyman-ws-tls","tls":"tls","sni":"'$domain_cdn'","type":"none","v":"2"}'
encoded_vmess=$(echo -n "$vmess" | base64 -w 0)
echo "vmess://$encoded_vmess"
echo ""
echo -e "${purple}--------------------------------VMESS-WS-TLS----------------------------${rest}"
echo "$vmess://$encoded_vmess" | qrencode -t ANSIUTF8
echo "vmess://$encoded_vmess" >"/root/peyman/configs/vmess_config.txt"
echo -e "${purple}----------------------------------------------------------------${rest}"
}
uninstall() {
# Check if the service is installed
if [ ! -f "/etc/systemd/system/s-box.service" ]; then
echo "The service is not installed."
return
fi
# Stop and disable the service
sudo systemctl stop s-box.service
sudo systemctl disable s-box.service >/dev/null 2>&1
# Remove service file
sudo rm /etc/systemd/system/s-box.service >/dev/null 2>&1
sudo rm -rf /etc/s-box
sudo rm -rf /root/peyman
sudo systemctl reset-failed
echo "Uninstallation completed."
}
config-sing-box() {
cat <<EOL >/root/peyman/configs/config-sing-box.json
{
"log": {
"level": "info",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "proxydns",
"address": "tls://8.8.8.8/dns-query",
"detour": "select"
},
{
"tag": "localdns",
"address": "h3://223.5.5.5/dns-query",
"detour": "direct"
},
{
"tag": "block",
"address": "rcode://refused"
},
{
"tag": "dns_fakeip",
"address": "fakeip"
}
],
"rules": [
{
"outbound": "any",
"server": "localdns",
"disable_cache": true
},
{
"clash_mode": "Global",
"server": "proxydns"
},
{
"clash_mode": "Direct",
"server": "localdns"
},
{
"rule_set": "geosite-cn",
"server": "localdns"
},
{
"rule_set": "geosite-geolocation-!cn",
"server": "proxydns"
},
{
"query_type": [
"A",
"AAAA"
],
"rule_set": "geosite-geolocation-!cn",
"server": "dns_fakeip"
}
],
"final": "proxydns",
"fakeip": {
"enabled": true,
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
},
"independent_cache": true
},
"ntp": {
"enabled": true,
"interval": "30m0s",
"server": "time.apple.com",
"server_port": 123,
"detour": "direct"
},
"inbounds": [
{
"type": "tun",
"auto_route": true,
"strict_route": true,
"sniff": true,
"sniff_override_destination": true,
"domain_strategy": "prefer_ipv4",
"inet4_address": "172.19.0.1/30",
"inet6_address": "fd00::1/126"
}
],
"outbounds": [
{
"type": "selector",
"tag": "select",
"outbounds": [
"auto",
"vless-tcp-reality",
"vless-grpc",
"vmess-sb",
"hy2-sb",
"tuic5-sb"
],
"default": "auto"
},
{
"type": "vless",
"tag": "vless-tcp-reality",
"server": "$domain",
"server_port": $vlessport,
"uuid": "$uuid",
"flow": "xtls-rprx-vision",
"tls": {
"enabled": true,
"server_name": "www.yahoo.com",
"utls": {
"enabled": true,
"fingerprint": "chrome"
},
"reality": {
"enabled": true,
"public_key": "$public_key",
"short_id": "$short_id"
}
}
},
{
"type": "vless",
"tag": "vless-grpc",
"server": "$domain_cdn",