Merge pull request #1111 from sofia-riese/patch-4

refactor(gateway): replace recursion with while loop
This commit is contained in:
juewuy
2026-01-11 08:08:48 +08:00
committed by GitHub

View File

@@ -10,6 +10,7 @@ __IS_MODULE_7_GATEWAY_LOADED=1
# 访问与控制主菜单 # 访问与控制主菜单
gateway() { gateway() {
while true; do
echo "-----------------------------------------------" echo "-----------------------------------------------"
echo -e "\033[30;47m欢迎使用访问与控制菜单\033[0m" echo -e "\033[30;47m欢迎使用访问与控制菜单\033[0m"
echo "-----------------------------------------------" echo "-----------------------------------------------"
@@ -26,7 +27,9 @@ gateway(){
echo "-----------------------------------------------" echo "-----------------------------------------------"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
case "$num" in case "$num" in
0) ;; "" | 0)
break
;;
1) 1)
echo "-----------------------------------------------" echo "-----------------------------------------------"
if [ -n "$(pidof CrashCore)" ] && [ "$firewall_mod" = 'iptables' ]; then if [ -n "$(pidof CrashCore)" ] && [ "$firewall_mod" = 'iptables' ]; then
@@ -35,23 +38,18 @@ gateway(){
else else
set_fw_wan set_fw_wan
fi fi
gateway
;; ;;
2) 2)
set_bot_tg set_bot_tg
gateway
;; ;;
3) 3)
. "$CRASHDIR"/menus/ddns.sh && ddns_menu . "$CRASHDIR"/menus/ddns.sh && ddns_menu
gateway
;; ;;
4) 4)
set_vmess set_vmess
gateway
;; ;;
5) 5)
set_shadowsocks set_shadowsocks
gateway
;; ;;
6) 6)
if echo "$crashcore" | grep -q 'sing'; then if echo "$crashcore" | grep -q 'sing'; then
@@ -60,7 +58,6 @@ gateway(){
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m" echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
sleep 1 sleep 1
fi fi
gateway
;; ;;
7) 7)
if echo "$crashcore" | grep -q 'sing'; then if echo "$crashcore" | grep -q 'sing'; then
@@ -69,11 +66,16 @@ gateway(){
echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m" echo -e "\033[33m$crashcore内核暂不支持此功能,请先更换内核!\033[0m"
sleep 1 sleep 1
fi fi
gateway
;; ;;
*) errornum ;; *)
errornum
sleep 1
break
;;
esac esac
done
} }
#公网防火墙 #公网防火墙
set_fw_wan() { set_fw_wan() {
[ -z "$fw_wan" ] && fw_wan=ON [ -z "$fw_wan" ] && fw_wan=ON