forked from hrostami/aio-proxy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
aio.sh
1855 lines (1623 loc) · 59 KB
/
aio.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
red='\033[0;31m'
bblue='\033[0;34m'
yellow='\033[0;33m'
green='\033[0;32m'
plain='\033[0m'
red(){ echo -e "\033[31m\033[01m$1\033[0m";}
green(){ echo -e "\033[32m\033[01m$1\033[0m";}
yellow(){ echo -e "\033[33m\033[01m$1\033[0m";}
blue(){ echo -e "\033[36m\033[01m$1\033[0m";}
white(){ echo -e "\033[37m\033[01m$1\033[0m";}
bblue(){ echo -e "\033[34m\033[01m$1\033[0m";}
rred(){ echo -e "\033[35m\033[01m$1\033[0m";}
readtp(){ read -t5 -n26 -p "$(yellow "$1")" $2;}
readp(){ read -p "$(yellow "$1")" $2;}
# install requirements
if ! command -v qrencode &> /dev/null || ! command -v jq &> /dev/null || ! dpkg -l | grep -q net-tools; then
sudo apt-get update
if ! command -v qrencode &> /dev/null; then
rred "qrencode is not installed. Installing..."
sudo apt-get install qrencode -y
# Check if installation was successful
if [ $? -eq 0 ]; then
red "qrencode is now installed."
else
red "Error: Failed to install qrencode."
fi
else
green "qrencode is already installed."
fi
if ! command -v jq &> /dev/null; then
rred "Installing jq..."
if sudo apt-get install jq -y; then
red "jq installed successfully."
else
red "Error: Failed to install jq."
exit 1
fi
else
green "jq is already installed."
fi
if ! dpkg -l | grep -q net-tools; then
rred "net-tools is not installed. Installing..."
sudo apt-get install net-tools -y
# Check if installation was successful
if [ $? -eq 0 ]; then
red "net-tools is now installed."
else
red "Error: Failed to install net-tools."
exit 1
fi
else
green "net-tools is already installed."
fi
else
green "qrencode, jq, and net-tools are already installed."
fi
# ----------------------------------------Show Menus------------------------------------------------
display_main_menu() {
clear
echo
echo
bblue " █████╗ ██╗ ██████╗ "
bblue " ██╔══██╗██║██╔═══██╗ "
bblue " ███████║██║██║ ██║ "
bblue " ██╔══██║██║██║ ██║ "
bblue " ██║ ██║██║╚██████╔╝ "
bblue " ╚═╝ ╚═╝╚═╝ ╚═════╝ "
bblue " All-in-one Proxy Tool "
white " Created by Hosy "
white "---------------------------------------------"
white " Github: https://github.com/hrostami"
white " Twitter: https://twitter.com/hosy000"
echo
yellow "-------------------Protocols------------------"
green "1. Hysteria 2. Hysteria V2"
echo
green "3. Tuic 4. Reality"
echo
green "5. SSH 6. Coming Soon..."
echo
yellow "---------------------Tools--------------------"
green "7. Reverse TLS Tunnel 8. Install Panels"
echo
green "9. Warp 10. Telegram Proxy"
echo
green "11. Show used Ports 12. Set Domains"
echo
rred "0. Exit"
echo "----------------------------------------------"
}
display_hysteria_menu() {
clear
echo "**********************************************"
yellow " Hysteria Menu "
echo "**********************************************"
green "1. Install/Update"
echo
green "2. Change Parameters"
echo
green "3. Show Configs"
echo
green "4. Delete"
echo
green "0. Back to Main Menu"
echo "**********************************************"
}
display_hysteria_v2_menu() {
clear
echo "**********************************************"
yellow " Hysteria V2 Menu "
echo "**********************************************"
green "1. Install/Update"
echo
green "2. Change Parameters"
echo
green "3. Show Configs"
echo
green "4. Delete"
echo
green "0. Back to Main Menu"
echo "**********************************************"
}
display_tuic_menu() {
clear
echo "**********************************************"
yellow " Tuic Menu "
echo "**********************************************"
green "1. Install/Update"
echo
green "2. Change Parameters"
echo
green "3. Show Configs"
echo
green "4. Delete"
echo
green "0. Back to Main Menu"
echo "**********************************************"
}
display_reality_menu() {
clear
white "---------------------------------------------"
echo -e "${plain}The script for RealityEZPZ is created by ${yellow}@Aleskxyz${plain}"
echo -e "Please check out and ${yellow}star ${plain}his Github repo"
echo -e "${yellow}https://github.com/aleskxyz/reality-ezpz${plain}"
white "---------------------------------------------"
echo
echo "**********************************************"
yellow " Reality Menu "
echo "**********************************************"
green "1. Install tcp"
echo
green "2. Install grpc"
echo
green "3. Show Configs"
echo
green "4. Change Port"
echo
green "5. Change SNI"
echo
green "6. Delete"
echo
green "0. Back to Main Menu"
echo "**********************************************"
}
display_ssh_menu() {
clear
echo "**********************************************"
yellow " SSH Menu "
echo "**********************************************"
green "1. Add user"
echo
green "2. Modify/Delete user"
echo
green "3. Show all users"
echo
green "0. Back to Main Menu"
echo "**********************************************"
}
display_install_panels_menu() {
clear
echo "**********************************************"
yellow " Panels Menu "
echo "**********************************************"
green "1. X-UI Alireza"
echo
green "2. X-UI Sanaei"
echo
green "3. RealityEZPZ by Aleskxyz"
echo
green "4. Hiddify"
echo
green "5. Marzban"
echo
green "0. Back to Main Menu"
echo "**********************************************"
}
display_warp_menu() {
clear
echo "**********************************************"
yellow " Warp Menu "
echo "**********************************************"
green "1. Install"
echo
green "2. Disable"
echo
green "3. Enable"
echo
green "0. Back to Main Menu"
echo "**********************************************"
white "Getting current IPs, please wait..."
IPV4=$(curl -s https://v4.ident.me)
if [ $? -ne 0 ]; then
echo "Error: Failed to get IPv4 address"
return
fi
IPV6=$(curl -s https://v6.ident.me)
if [ $? -ne 0 ]; then
echo "Error: Failed to get IPv6 address"
return
fi
echo -e "${plain}IPv4:${red} $IPV4${plain}"
echo -e "${plain}IPv6:${red} $IPV6${plain}"
echo "**********************************************"
}
display_telegram_menu() {
clear
white "---------------------------------------------"
echo -e "This part's script is created by ${yellow}@HirbodBehnam${plain}"
echo -e "Please check out and ${yellow}star ${plain}his Github repo"
echo -e "${yellow}https://github.com/HirbodBehnam/MTProtoProxyInstaller${plain}"
white "---------------------------------------------"
echo
echo "**********************************************"
yellow " Telegram Menu "
echo "**********************************************"
green "1. Python(for 1 core/lowend servers)"
echo
green "2. Official Method"
echo
green "3. Golang"
echo
green "4. Erlang"
echo
green "0. Back to Main Menu"
echo "**********************************************"
}
display_domains_menu() {
clear
echo "**********************************************"
yellow " Domains Menu "
echo "**********************************************"
green "1. IPv4 Domain"
echo
green "2. IPv6 Domain"
echo
green "3. Cert + Nginx Setup"
echo
green "4. NAT Nginx Setup (get certs manually from Cloudflare)"
echo
green "0. Back to Main Menu"
echo "**********************************************"
echo -e "${plain}IPv4 Domain:${red} $IPV4_DOMAIN${plain}"
echo -e "${plain}IPv6 Domain:${red} $IPV6_DOMAIN${plain}"
echo "**********************************************"
}
# ----------------------------------------Hysteria stuff------------------------------------------------
run_hysteria_setup() {
clear
echo "Running Hysteria Setup..."
sleep 2
#!/bin/bash
apt-get update
apt-get install wget nano -y
apt-get install net-tools -y
if [ "$EUID" -eq 0 ]; then
user_directory="/root/hy"
else
user_directory="/home/$USER/hy"
fi
if [ -d "$user_directory" ]; then
clear
echo "--------------------------------------------------------------------------------"
echo -e "\e[1;33mHysteria directory already exists. Checking for latest version..\e[0m"
echo "--------------------------------------------------------------------------------"
sleep 2
if [ -f "$user_directory/config.json" ]; then
port=$(jq -r '.listen' "$user_directory/config.json" | cut -c 2-)
password=$(jq -r '.obfs' "$user_directory/config.json")
else
echo "Error: config.json file not found in Hysteria directory."
return
fi
else
readp "Enter the listening port: " port
readp "Enter the obfuscation password: " password
mkdir -p "$user_directory"
cd "$user_directory"
cat << EOF > "$user_directory/config.json"
{
"listen": ":$port",
"cert": "$user_directory/ca.crt",
"key": "$user_directory/ca.key",
"obfs": "$password",
"recv_window_conn": 3407872,
"recv_window": 13631488,
"disable_mtu_discovery": true,
"resolver": "https://223.5.5.5/dns-query"
}
EOF
fi
# latest_version=$(curl -s https://api.github.com/repos/apernet/hysteria/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
latest_version="v1.3.5"
echo -e "\e[1;33m---> Installing hysteria ver $latest_version\e[0m"
echo "--------------------------------------------------------------------------------"
sleep 2
rm hysteria-linux-amd64
architecture=$(uname -m)
if [ "$architecture" = "x86_64" ]; then
wget "https://github.com/apernet/hysteria/releases/download/$latest_version/hysteria-linux-amd64"
else
wget "https://github.com/apernet/hysteria/releases/download/$latest_version/hysteria-linux-arm"
mv hysteria-linux-arm hysteria-linux-amd64
fi
chmod 755 hysteria-linux-amd64
# Generate encryption keys if they don't exist
if [ ! -f "$user_directory/ca.key" ] || [ ! -f "$user_directory/ca.crt" ]; then
openssl ecparam -genkey -name prime256v1 -out "$user_directory/ca.key"
openssl req -new -x509 -days 36500 -key "$user_directory/ca.key" -out "$user_directory/ca.crt" -subj "/CN=bing.com"
fi
# Create a systemd service for hysteria if it doesn't exist
if [ ! -f "/etc/systemd/system/hy.service" ]; then
cat << EOF > /etc/systemd/system/hy.service
[Unit]
After=network.target nss-lookup.target
[Service]
User=root
WorkingDirectory=$user_directory
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
ExecStart=$user_directory/hysteria-linux-amd64 -c $user_directory/config.json server
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=5
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable hy
fi
systemctl restart hy
}
show_hy_configs() {
local user_directory
if [ "$EUID" -eq 0 ]; then
user_directory="/root/hy"
else
user_directory="/home/$USER/hy"
fi
if [ -d "$user_directory" ]; then
echo "Here are the current configurations:"
password=$(jq -r '.obfs' "$user_directory/config.json")
port=$(jq -r '.listen' "$user_directory/config.json" | cut -c 2-)
systemctl stop wg-quick@wgcf
if [ -z "$IPV4_DOMAIN" ]; then
IPV4=$(curl -s https://v4.ident.me)
else
IPV4="$IPV4_DOMAIN"
fi
if [ -z "$IPV6_DOMAIN" ]; then
IPV6=$(curl -s https://v6.ident.me)
else
IPV6="$IPV6_DOMAIN"
fi
systemctl restart wg-quick@wgcf
IPV4_URL="hysteria://$IPV4:$port?protocol=udp&insecure=1&upmbps=100&downmbps=100&obfs=xplus&obfsParam=$password#hysteria IPv4"
IPV6_URL="hysteria://[$IPV6]:$port?protocol=udp&insecure=1&upmbps=100&downmbps=100&obfs=xplus&obfsParam=$password#hysteria IPv6"
echo "----------------config info-----------------"
echo -e "\e[1;33mPassword: $password\e[0m"
echo "--------------------------------------------"
echo
echo "----------------IP and Port-----------------"
echo -e "\e[1;33mPort: $port\e[0m"
echo -e "\e[1;33mIPv4: $IPV4\e[0m"
echo -e "\e[1;33mIPv6: $IPV6\e[0m"
echo "--------------------------------------------"
echo
echo "----------------Hysteria Config IPv4-----------------"
echo -e "\e[1;33m$IPV4_URL\e[0m"
qrencode -t ANSIUTF8 "$IPV4_URL"
echo "--------------------------------------------"
echo
echo "-----------------Hysteria Config IPv6----------------"
echo -e "\e[1;33m$IPV6_URL\e[0m"
qrencode -t ANSIUTF8 "$IPV6_URL"
echo "--------------------------------------------"
else
echo "Hysteria directory does not exist. Please install Hysteria first."
fi
readp "Press Enter to continue..."
}
change_hy_parameters() {
local user_directory
if [ "$EUID" -eq 0 ]; then
user_directory="/root/hy"
else
user_directory="/home/$USER/hy"
fi
if [ -d "$user_directory" ]; then
echo "Hysteria directory exists. You can change parameters here."
port=$(jq -r '.listen' "$user_directory/config.json" | cut -c 2-)
password=$(jq -r '.obfs' "$user_directory/config.json")
readp "Enter a new listening port [$port]: " new_port
readp "Enter a new obfuscation password [$password]: " new_password
# Update the config.json file with the new or existing values
jq ".listen = \":${new_port:-$port}\" | .obfs = \"$new_password\"" "$user_directory/config.json" > tmp_config.json
mv tmp_config.json "$user_directory/config.json"
systemctl restart hy
echo "Parameters updated successfully."
else
echo "Hysteria directory does not exist. Please install Hysteria first."
fi
}
delete_hysteria() {
clear
echo "Deleting Hysteria Proxy..."
sleep 2
rm -r ~/hy
systemctl stop hy
systemctl disable hy
readp "Press Enter to continue..."
}
# ----------------------------------------Hysteria V2 stuff------------------------------------------------
run_hysteria_v2_setup() {
clear
echo "Running Hysteria v2 Setup..."
sleep 2
#!/bin/bash
apt-get update
apt-get install wget nano -y
apt-get install net-tools -y
if [ "$EUID" -eq 0 ]; then
user_directory="/root/hy2"
else
user_directory="/home/$USER/hy2"
fi
if [ -d "$user_directory" ]; then
clear
echo "--------------------------------------------------------------------------------"
echo -e "\e[1;33mHysteria directory already exists. Checking for latest version..\e[0m"
echo "--------------------------------------------------------------------------------"
sleep 2
if [ -f "$user_directory/config.json" ]; then
port=$(jq -r '.listen' <<< "$(< "$user_directory/config.json")" | cut -c 2-)
password=$(jq -r '.obfs.salamander.password' <<< "$(< "$user_directory/config.json")")
else
echo "Error: config.json file not found in Hysteria directory."
return
fi
else
readp "Enter the listening port: " port
readp "Enter the obfuscation password: " password
mkdir -p "$user_directory"
cd "$user_directory"
cat << EOF > "$user_directory/config.json"
{
"listen": ":$port",
"tls": {
"cert": "$user_directory/ca.crt",
"key": "$user_directory/ca.key"
},
"obfs": {
"type": "salamander",
"salamander": {
"password": "$password"
}
},
"auth": {
"type": "password",
"password": "$password"
},
"quic": {
"initStreamReceiveWindow": 8388608,
"maxStreamReceiveWindow": 8388608,
"initConnReceiveWindow": 20971520,
"maxConnReceiveWindow": 20971520,
"maxIdleTimeout": "60s",
"maxIncomingStreams": 1024,
"disablePathMTUDiscovery": false
},
"bandwidth": {
"up": "1 gbps",
"down": "1 gbps"
},
"ignoreClientBandwidth": false,
"disableUDP": false,
"udpIdleTimeout": "60s",
"resolver": {
"type": "udp",
"tcp": {
"addr": "8.8.8.8:53",
"timeout": "4s"
},
"udp": {
"addr": "8.8.4.4:53",
"timeout": "4s"
},
"tls": {
"addr": "1.1.1.1:853",
"timeout": "10s",
"sni": "cloudflare-dns.com",
"insecure": false
},
"https": {
"addr": "1.1.1.1:443",
"timeout": "10s",
"sni": "cloudflare-dns.com",
"insecure": false
}
}
}
EOF
fi
latest_version=$(curl -s https://api.github.com/repos/apernet/hysteria/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
echo -e "\e[1;33m---> Installing hysteria ver $latest_version\e[0m"
echo "--------------------------------------------------------------------------------"
sleep 2
rm hysteria-linux-amd64
architecture=$(uname -m)
if [ "$architecture" = "x86_64" ]; then
wget "https://github.com/apernet/hysteria/releases/download/$latest_version/hysteria-linux-amd64"
else
wget "https://github.com/apernet/hysteria/releases/download/$latest_version/hysteria-linux-arm"
mv hysteria-linux-arm hysteria-linux-amd64
fi
chmod 755 hysteria-linux-amd64
if [ ! -f "$user_directory/ca.key" ] || [ ! -f "$user_directory/ca.crt" ]; then
openssl ecparam -genkey -name prime256v1 -out "$user_directory/ca.key"
openssl req -new -x509 -days 36500 -key "$user_directory/ca.key" -out "$user_directory/ca.crt" -subj "/CN=bing.com"
fi
if [ ! -f "/etc/systemd/system/hy2.service" ]; then
cat << EOF > /etc/systemd/system/hy2.service
[Unit]
After=network.target nss-lookup.target
[Service]
User=root
WorkingDirectory=$user_directory
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
ExecStart=$user_directory/hysteria-linux-amd64 -c $user_directory/config.json server
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=5
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable hy2
fi
systemctl restart hy2
}
change_hy2_parameters() {
local user_directory
if [ "$EUID" -eq 0 ]; then
user_directory="/root/hy2"
else
user_directory="/home/$USER/hy2"
fi
if [ -d "$user_directory" ]; then
echo "Hysteria directory exists. You can change parameters here."
port=$(jq -r '.listen' "$user_directory/config.json" | cut -c 2-)
password=$(jq -r '.obfs.salamander.password' "$user_directory/config.json")
readp "Enter a new listening port [$port]: " new_port
readp "Enter a new obfuscation password [$password]: " new_password
jq ".listen = \":${new_port:-$port}\" | .obfs.salamander.password = \"$new_password\"" "$user_directory/config.json" > tmp_config.json
mv tmp_config.json "$user_directory/config.json"
systemctl restart hy2
echo "Parameters updated successfully."
else
echo "Hysteria directory does not exist. Please install Hysteria first."
fi
}
show_hy2_configs() {
local user_directory
if [ "$EUID" -eq 0 ]; then
user_directory="/root/hy2"
else
user_directory="/home/$USER/hy2"
fi
if [ -d "$user_directory" ]; then
echo "Hysteria directory exists. Here are the current configurations:"
password=$(jq -r '.obfs.salamander.password' "$user_directory/config.json")
port=$(jq -r '.listen' "$user_directory/config.json" | cut -c 2-)
systemctl stop wg-quick@wgcf
if [ -z "$IPV4_DOMAIN" ]; then
IPV4=$(curl -s https://v4.ident.me)
else
IPV4="$IPV4_DOMAIN"
fi
if [ -z "$IPV6_DOMAIN" ]; then
IPV6=$(curl -s https://v6.ident.me)
else
IPV6="$IPV6_DOMAIN"
fi
systemctl restart wg-quick@wgcf
v2rayN_config="server: $IPV6:$port
auth: $password
transport:
type: udp
udp:
hopInterval: 30s
obfs:
type: salamander
salamander:
password: $password
tls:
sni: google.com
insecure: true
bandwidth:
up: 100 mbps
down: 100 mbps
quic:
initStreamReceiveWindow: 8388608
maxStreamReceiveWindow: 8388608
initConnReceiveWindow: 20971520
maxConnReceiveWindow: 20971520
maxIdleTimeout: 30s
keepAlivePeriod: 10s
disablePathMTUDiscovery: false
fastOpen: true
lazy: true
socks5:
listen: 127.0.0.1:10808
http:
listen: 127.0.0.1:10809"
IPV4_URL="hysteria2://$password@$IPV4:$port/?insecure=1&obfs=salamander&obfs-password=$password&sni=google.com#HysteriaV2 IPv4"
IPV6_URL="hysteria2://$password@[$IPV6]:$port/?insecure=1&obfs=salamander&obfs-password=$password&sni=google.com#HysteriaV2 IPv6"
echo "----------------config info-----------------"
echo -e "\e[1;33mPassword: $password\e[0m"
echo "--------------------------------------------"
echo
echo "----------------IP and Port-----------------"
echo -e "\e[1;33mPort: $port\e[0m"
echo -e "\e[1;33mIPv4: $IPV4\e[0m"
echo -e "\e[1;33mIPv6: $IPV6\e[0m"
echo "--------------------------------------------"
echo
echo "----------------V2rayN Config IPv6-----------------"
echo -e "\e[1;33m$v2rayN_config\e[0m"
echo "--------------------------------------------"
echo
echo "----------------Nekobox Config IPv4-----------------"
echo -e "\e[1;33m$IPV4_URL\e[0m"
qrencode -t ANSIUTF8 "$IPV4_URL"
echo "--------------------------------------------"
echo
echo "-----------------Nekobox Config IPv6----------------"
echo -e "\e[1;33m$IPV6_URL\e[0m"
qrencode -t ANSIUTF8 "$IPV6_URL"
echo "--------------------------------------------"
else
echo "Hysteria directory does not exist. Please install Hysteria first."
fi
readp "Press Enter to continue..."
}
delete_hysteria_v2() {
clear
echo "Deleting Hysteria v2 Proxy..."
sleep 2
rm -r ~/hy2
systemctl stop hy2
systemctl disable hy2
readp "Press Enter to continue..."
}
# ----------------------------------------TUIC stuff------------------------------------------------
run_tuic_setup() {
clear
echo "Running Tuic Setup..."
sleep 2
#!/bin/bash
# Determine the appropriate TUIC_FOLDER based on the user
if [ "$EUID" -eq 0 ]; then
TUIC_FOLDER="/root/tuic"
WORKING_DIR="/root"
else
TUIC_FOLDER="$HOME/tuic"
WORKING_DIR="$HOME"
fi
CONFIG_FILE="$TUIC_FOLDER/config.json"
# Detect server architecture
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
TUIC_ARCH="x86_64-unknown-linux-gnu"
elif [ "$ARCH" = "aarch64" ]; then
TUIC_ARCH="aarch64-unknown-linux-gnu"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
# Fetch all releases from the GitHub API
ALL_VERSIONS=$(curl -s "https://api.github.com/repos/EAimTY/tuic/releases" | jq -r '.[].tag_name')
# Find the latest TUIC server version
LATEST_SERVER_VERSION=""
for VERSION in $ALL_VERSIONS; do
if [[ "$VERSION" == *"tuic-server-"* && "$VERSION" =~ ^tuic-server-[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
LATEST_SERVER_VERSION=$VERSION
break
fi
done
if [ -z "$LATEST_SERVER_VERSION" ]; then
echo "No TUIC server version found in GitHub releases."
exit 1
fi
# Construct the URL for the latest TUIC server binary
TUIC_URL="https://github.com/EAimTY/tuic/releases/download/$LATEST_SERVER_VERSION/$LATEST_SERVER_VERSION-$TUIC_ARCH"
# Check if TUIC directory exists
if [ -d "$TUIC_FOLDER" ]; then
systemctl stop tuic
clear
echo "--------------------------------------------------------------------------------"
echo -e "\e[1;33m TUIC directory already exists. Checking for latest version..\e[0m"
echo "--------------------------------------------------------------------------------"
sleep 2
# Directory exists, download the latest version of TUIC
cd "$TUIC_FOLDER"
echo -e "\e[1;33m---> Installing $LATEST_SERVER_VERSION\e[0m"
echo "--------------------------------------------------------------------------------"
sleep 2
# Construct the URL for the latest TUIC server binary
TUIC_URL="https://github.com/EAimTY/tuic/releases/download/$LATEST_SERVER_VERSION/$LATEST_SERVER_VERSION-$TUIC_ARCH"
# Download the latest TUIC server binary
wget -O tuic-server "$TUIC_URL"
chmod 755 tuic-server
# Get password, port, and congestion from config file
PORT=$(jq -r '.server' "$CONFIG_FILE" | awk -F ':' '{print $NF}')
CONGESTION_CONTROL=$(jq -r '.congestion_control' "$CONFIG_FILE")
UUID=$(jq -r '.users | keys[0]' "$CONFIG_FILE")
PASSWORD=$(jq -r ".users[\"$UUID\"]" "$CONFIG_FILE")
# Restart the service
systemctl restart tuic
else
# Update packages
apt update
apt install nano net-tools uuid-runtime wget openssl -y
# Create TUIC directory and navigate to it
mkdir -p "$TUIC_FOLDER"
cd "$TUIC_FOLDER"
# Download the latest TUIC server binary
clear
echo "--------------------------------------------------------------------------------"
echo -e "\e[1;33m---> Installing $LATEST_SERVER_VERSION\e[0m"
echo "--------------------------------------------------------------------------------"
sleep 2
wget -O tuic-server "$TUIC_URL"
chmod 755 tuic-server
# Generate certificate
openssl ecparam -genkey -name prime256v1 -out "$TUIC_FOLDER/ca.key"
openssl req -new -x509 -days 36500 -key "$TUIC_FOLDER/ca.key" -out "$TUIC_FOLDER/ca.crt" -subj "/CN=bing.com"
# Generate random UUID
UUID=$(uuidgen)
# Prompt for port
readp "Enter port number: " PORT
# Prompt for password
readp "Enter a password for the server: " PASSWORD
# Prompt for congestion control
OPTIONS=("cubic" "new_reno" "bbr")
PS3='Select congestion control: '
select OPT in "${OPTIONS[@]}"
do
CONGESTION_CONTROL=$OPT
break
done
# Create config file
cat <<EOF >"$CONFIG_FILE"
{
"server": "[::]:$PORT",
"users": {
"${UUID}": "$PASSWORD"
},
"certificate": "$TUIC_FOLDER/ca.crt",
"private_key": "$TUIC_FOLDER/ca.key",
"congestion_control": "$CONGESTION_CONTROL",
"alpn": ["h3", "spdy/3.1"],
"udp_relay_ipv6": true,
"zero_rtt_handshake": false,
"dual_stack": true,
"auth_timeout": "3s",
"task_negotiation_timeout": "3s",
"max_idle_time": "10s",
"max_external_packet_size": 1500,
"send_window": 16777216,
"receive_window": 8388608,
"gc_interval": "3s",
"gc_lifetime": "15s",
"log_level": "warn"
}
EOF
# Determine the user for the service
SERVICE_USER="root"
if [ "$EUID" -ne 0 ]; then
SERVICE_USER="$USER"
fi
cat <<EOF > /etc/systemd/system/tuic.service
[Unit]
Description=tuic service
After=network.target nss-lookup.target
[Service]
User=$SERVICE_USER
WorkingDirectory=$WORKING_DIR
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
ExecStart=$WORKING_DIR/tuic/tuic-server -c $WORKING_DIR/tuic/config.json
Restart=on-failure
RestartSec=10
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
EOF
# Reload and start service
systemctl daemon-reload
systemctl enable tuic
systemctl start tuic
fi
}
show_tuic_configs() {
local TUIC_FOLDER
local CONFIG_FILE
if [ "$EUID" -eq 0 ]; then
TUIC_FOLDER="/root/tuic"
else
TUIC_FOLDER="$HOME/tuic"
fi
CONFIG_FILE="$TUIC_FOLDER/config.json"
if [ -d "$TUIC_FOLDER" ]; then
echo "Here are the current configurations:"
PORT=$(jq -r '.server' "$CONFIG_FILE" | awk -F ':' '{print $NF}')
CONGESTION_CONTROL=$(jq -r '.congestion_control' "$CONFIG_FILE")
UUID=$(jq -r '.users | keys[0]' "$CONFIG_FILE")
PASSWORD=$(jq -r ".users[\"$UUID\"]" "$CONFIG_FILE")
systemctl stop wg-quick@wgcf
if [ -z "$IPV4_DOMAIN" ]; then
IPV4=$(curl -s https://v4.ident.me)
else
IPV4="$IPV4_DOMAIN"
fi
if [ -z "$IPV6_DOMAIN" ]; then
IPV6=$(curl -s https://v6.ident.me)
else
IPV6="$IPV6_DOMAIN"
fi
systemctl restart wg-quick@wgcf
IPV4_URL="tuic://$UUID:$PASSWORD@$IPV4:$PORT/?congestion_control=$CONGESTION_CONTROL&udp_relay_mode=native&alpn=h3,spdy/3.1&allow_insecure=1#Tuic IPv4"
IPV6_URL="tuic://$UUID:$PASSWORD@[$IPV6]:$PORT/?congestion_control=$CONGESTION_CONTROL&udp_relay_mode=native&alpn=h3,spdy/3.1&allow_insecure=1#Tuic IPv6"
echo "----------------config info-----------------"
echo -e "\e[1;33mUUID: $UUID\e[0m"
echo -e "\e[1;33mPassword: $PASSWORD\e[0m"
echo "--------------------------------------------"
echo
echo "----------------IP and Port-----------------"
echo -e "\e[1;33mPort: $PORT\e[0m"
echo -e "\e[1;33mIPv4: $IPV4\e[0m"
echo -e "\e[1;33mIPv6: $IPV6\e[0m"
echo "--------------------------------------------"
echo
echo "----------------Tuic Config IPv4-----------------"