refactor(set_adv_config): replace recursion with while loop

This commit is contained in:
Sofia
2026-01-11 12:51:18 +08:00
committed by GitHub
parent 55b8266dfd
commit 7676a3f607

View File

@@ -281,22 +281,25 @@ set_redir_mod() {
done
}
set_adv_config() { #端口设置
. "$CFG_PATH" >/dev/null
[ -z "$secret" ] && secret=未设置
[ -z "$table" ] && table=100
[ -z "$authentication" ] && auth=未设置 || auth=******
inputport() {
read -p "请输入端口号(1-65535) > " portx
. "$CRASHDIR"/menus/check_port.sh # 加载测试函数
if check_port "$portx"; then
setconfig "$xport" "$portx"
echo -e "\033[32m设置成功\033[0m"
set_adv_config
else
sleep 1
echo -e "\033[31m设置失败\033[0m"
fi
sleep 1
}
# 端口设置
set_adv_config() {
while true; do
. "$CFG_PATH" >/dev/null
[ -z "$secret" ] && secret=未设置
[ -z "$table" ] && table=100
[ -z "$authentication" ] && auth=未设置 || auth=******
echo "-----------------------------------------------"
echo -e " 1 修改Http/Sock5端口 \033[36m$mix_port\033[0m"
echo -e " 2 设置Http/Sock5密码 \033[36m$auth\033[0m"
@@ -309,7 +312,9 @@ set_adv_config() { #端口设置
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
case "$num" in
0) ;;
"" | 0)
break
;;
1)
xport=mix_port
inputport
@@ -324,7 +329,7 @@ set_adv_config() { #端口设置
if [ "$input" = "0" ]; then
authentication=""
setconfig authentication
echo 密码已移除!
echo "密码已移除!"
else
if [ "$local_proxy" = "ON" -a "$local_type" = "环境变量" ]; then
echo "-----------------------------------------------"
@@ -340,7 +345,6 @@ set_adv_config() { #端口设置
fi
fi
fi
set_adv_config
;;
3)
xport=redir_port
@@ -361,7 +365,6 @@ set_adv_config() { #端口设置
setconfig secret $secret
echo -e "\033[32m设置成功\033[0m"
fi
set_adv_config
;;
8)
echo "-----------------------------------------------"
@@ -382,7 +385,6 @@ set_adv_config() { #端口设置
echo -e "\033[31m输入错误请仔细核对\033[0m"
fi
sleep 1
set_adv_config
;;
9)
echo "-----------------------------------------------"
@@ -393,13 +395,16 @@ set_adv_config() { #端口设置
setconfig table "$table"
echo -e "\033[32m设置成功\033[0m"
fi
set_adv_config
;;
*)
errornum
sleep 1
break
;;
esac
done
}
set_firewall_area() { #路由范围设置
[ -z "$vm_redir" ] && vm_redir='OFF'
echo "-----------------------------------------------"