-
Notifications
You must be signed in to change notification settings - Fork 14
/
menu.sh
367 lines (347 loc) · 11.5 KB
/
menu.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
#!/bin/bash
for script in /opt/hiddify-relay/scripts/*.sh; do
source "$script"
done
# Graphical functionality for IP-Tables menu
iptables_menu() {
while true; do
choice=$(whiptail --backtitle "Hiddify Relay Builder" --title "IP-Tables Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install IP-Tables Rules" \
"Status" "Check Ports In Use" \
"Uninstall" "Uninstall IP-Tables Rules" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $choice in
Install)
install_iptables
;;
Status)
check_port_iptables
;;
Uninstall)
uninstall_iptables
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
# Graphical functionality for GOST menu
gost_menu() {
while true; do
choice=$(whiptail --backtitle "Hiddify Relay Builder" --title "GOST Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install GOST" \
"Status" "Check GOST Port And Status" \
"Add" "Add Another Port And Domain" \
"Remove" "Remove Port And Domain" \
"Uninstall" "Uninstall GOST" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $choice in
Install)
install_gost
;;
Status)
check_port_gost
;;
Add)
add_port_gost
;;
Remove)
remove_port_gost
;;
Uninstall)
uninstall_gost
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
dokodemo_menu() {
while true; do
choice=$(whiptail --backtitle "Hiddify Relay Builder" --title "Dokodemo-Door Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install Xray For Dokodemo-Door And Add Inbound" \
"Status" "Check Xray Service Status" \
"Traffic" "Inbound Traffic Statistics" \
"Add" "Add Another Inbound" \
"Remove" "Remove an Inbound Configuration" \
"Uninstall" "Uninstall Xray And Tunnel" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $choice in
Install)
install_xray
;;
Status)
check_service_xray
;;
Traffic)
trafficstat
;;
Add)
add_another_inbound
;;
Remove)
remove_inbound
;;
Uninstall)
uninstall_xray
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
# Graphical functionality for Socat menu
haproxy_menu() {
while true; do
choice=$(whiptail --backtitle "Hiddify Relay Builder" --title "HA-Proxy Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install HA-Proxy" \
"Status" "Check HA-Proxy Port and Status" \
"Add" "Add more tunnel Configuration" \
"Remove" "Remove tunnel Configuration" \
"Uninstall" "Uninstall HAProxy" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $choice in
Install)
install_haproxy
;;
Status)
check_haproxy
;;
Add)
add_frontend_backend
;;
Remove)
remove_frontend_backend
;;
Uninstall)
uninstall_haproxy
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
# Graphical functionality for Socat menu
socat_menu() {
while true; do
choice=$(whiptail --backtitle "Hiddify Relay Builder" --title "Socat Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install Socat And Setup Tunnel Service" \
"Status" "Check Socat Port" \
"Uninstall" "Uninstall Socat And Remove Tunnel Service" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $choice in
Install)
install_socat
;;
Status)
check_socat_port
;;
Uninstall)
uninstall_socat
;;
Back)
DeprecatedTunnel
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
# Graphical functionality for WSTunnel menu
wstunnel_menu() {
while true; do
choice=$(whiptail --backtitle "Hiddify Relay Builder" --title "WS-Tunnel Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install And Configure WS-Tunnel" \
"Status" "Check WS-Tunnel Service And Port" \
"Uninstall" "Uninstall WS-Tunnel From Both Servers" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $choice in
Install)
install_wstunnel
;;
Status)
check_wstunnel_port
;;
Uninstall)
uninstall_wstunnel
;;
Back)
DeprecatedTunnel
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
# Define the submenu for Other Options
function other_options_menu() {
while true; do
other_choice=$(whiptail --backtitle "Welcome to Hiddify Relay Builder" --title "Other Options" --menu "Please choose one of the following options:" 20 60 10 \
"DNS" "Configure DNS" \
"Update" "Update Server" \
"Ping" "Ping to check internet connectivity" \
"DeprecatedTunnel" "No longer supported"\
"Back" "Return to Main Menu" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $other_choice in
DNS)
configure_dns
;;
Update)
update_server
;;
Ping)
ping_websites
;;
DeprecatedTunnel)
DeprecatedTunnel
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
;;
esac
else
exit 1
fi
done
}
#################################
# Define the main graphical menu
function DeprecatedTunnel() {
while true; do
choice=$(whiptail --backtitle "Welcome to Hiddify Relay Builder" --title "Choose Your Tunnel Mode" --menu "Please choose one of the following options:" 20 60 10 \
"Socat" "Manage Socat Tunnel" \
"WST" "Manage Web Socket Tunnel"\
"Back" "Return to Main Menu" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $choice in
Socat)
socat_menu
;;
WST)
wstunnel_menu
;;
Back)
other_options_menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
;;
esac
else
exit 1
fi
done
}
#################################
# Define the main graphical menu
function menu() {
while true; do
choice=$(whiptail --backtitle "Welcome to Hiddify Relay Builder" --title "Choose Your Tunnel Mode" --menu "Please choose one of the following options:" 20 60 10 \
"IP-Tables" "Manage IP-Tables Tunnel" \
"GOST" "Manage GOST Tunnel" \
"Dokodemo-Door" "Manage Dokodemo-Door Tunnel" \
"HA-Proxy" "Manage HA-Proxy Tunnel" \
"Options" "Additional Configuration Options" \
"Quit" "Exit From The Script" 3>&1 1>&2 2>&3)
# Check the return value of the whiptail command
if [ $? -eq 0 ]; then
# Check if the user selected a valid option
case $choice in
IP-Tables)
iptables_menu
;;
GOST)
gost_menu
;;
Dokodemo-Door)
dokodemo_menu
;;
HA-Proxy)
haproxy_menu
;;
Options)
other_options_menu
;;
Quit)
exit 0
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
# Call the menu function
menu