-
Notifications
You must be signed in to change notification settings - Fork 126
/
t.sh
123 lines (112 loc) · 2.83 KB
/
t.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
#!/bin/bash
# By Hamed Ap
# For Shahan Panel :) Dozdi Nakon BiShoor :))
printshahan() {
text="$1"
delay="$2"
for ((i=0; i<${#text}; i++)); do
echo -n "${text:$i:1}"
sleep $delay
done
echo
}
clear
echo ""
printshahan "Tuic For ShaHaN Panel :) By HamedAp" 0.1
echo ""
echo ""
printshahan "Please Wait . . ." 0.1
echo ""
echo ""
sudo apt update -y > /dev/null 2>&1
sudo apt install curl jq openssl uuid-runtime -y > /dev/null 2>&1
detect_arch() {
local arch=$(uname -m)
case $arch in
x86_64)
echo "x86_64-linux"
;;
i686)
echo "i686-linux"
;;
armv7l)
echo "armv7-linux"
;;
aarch64)
echo "aarch64-linux"
;;
*)
echo "Unsupported architecture: $arch"
exit 1
;;
esac
}
server_arch=$(detect_arch)
download_url="https://github.com/HamedAp/tuic/releases/download/1.1.2/tuic-server-$server_arch"
mkdir -p /root/tuic
cd /root/tuic
rm -fr /root/tuic/tuic-server
sudo wget -4 -O /root/tuic/tuic-server -q "$download_url"
if [[ $? -ne 0 ]]; then
echo "Failed to download the tuic binary."
exit 1
fi
chmod 755 tuic-server
openssl ecparam -genkey -name prime256v1 -out ca.key
openssl req -new -x509 -days 36500 -key ca.key -out ca.crt -subj "/CN=bing.com"
echo ""
read -p "Enter a port (or press enter for a random port between 10000 and 65000): " port
echo ""
[ -z "$port" ] && port=$((RANDOM % 55001 + 10000))
UUID=$(uuidgen)
if [ -z "$UUID" ]; then
echo "Error: Failed to generate UUID."
exit 1
fi
cp /root/tuic/config.json /var/www/config.json
cat > /var/www/config.json <<EOL
{
"server": "[::]:$port",
"users": {
"$UUID": "shahan"
},
"certificate": "/root/tuic/ca.crt",
"private_key": "/root/tuic/ca.key",
"congestion_control": "bbr",
"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,
"gc_interval": "3s",
"gc_lifetime": "15s",
"restful_server":"127.0.0.1:6190"
}
EOL
cat > /etc/systemd/system/tuic.service <<EOL
[Unit]
Description=tuic service
Documentation=TUIC v5
After=network.target nss-lookup.target
[Service]
User=root
WorkingDirectory=/root/tuic
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW
ExecStart=/root/tuic/tuic-server -c /var/www/config.json
Restart=on-failure
RestartSec=10
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
EOL
systemctl daemon-reload
systemctl enable tuic > /dev/null 2>&1
systemctl restart tuic
chmod 646 /var/www/config.json
chown www-data:www-data /var/www/config.json
clear
echo "TUIC 1.1.3 With OnlineList Installed :)"