From 56202723c7ad3d8fe3715d099bab74403ed1a79a Mon Sep 17 00:00:00 2001 From: Olia Lisa Date: Thu, 21 May 2026 16:22:44 +0800 Subject: [PATCH] udpate --- bin/port.sh | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/bin/port.sh b/bin/port.sh index 4652302..a7bf9b0 100644 --- a/bin/port.sh +++ b/bin/port.sh @@ -166,30 +166,20 @@ port_manage() { # ========================================== # 更新 sing-box 配置文件中的监听端口,并开放对应防火墙规则 -# 参数1: 端口号(可选,不传则在指定范围内随机选取空闲端口) -# 参数2: 随机端口起始值(可选,默认 5000) -# 参数3: 随机端口结束值(可选,默认 15000) +# 参数: 端口号(可选,不传则设置一个5000 到 15000的空闲端口) # --- 使用示例 --- # 指定端口 # update_port 8080 -# -# 自动随机端口(默认范围 5000-15000) -# update_port -# -# 自动随机端口(自定义范围) -# update_port "" 20000 30000 # ========================================== update_port(){ - local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 - - local config_dir="$script_dir/../config" - local port=$1 # 如果没有提供端口参数,则自动查找一个随机空闲端口 if [[ -z "$port" ]]; then port=$(find_free_port 5000 15000) fi + local script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 + local config_dir="$script_dir/../config" modify_json_file "$config_dir/config.json" ".inbounds[0].listen_port" "$port" port_manage allow "$port" echo "设置端口成功"