Skip to content

Commit e5d90df

Browse files
committed
fix: fix UUID/subscription on BusyBox and align quick-install defaults
- read UUID_CONFIRM from conf JSON via field-based awk -F '"' lookup and from nginx.conf location path segments via sed, avoiding {n} quantifier regex unsupported by BusyBox/Mawk; prevents a random UUID leaking into subscription links after changing UUID in -d - hide the Hysteria2 Realm/port-hopping mutual-exclusion prompt in -l / -K / noninteractive installs where Realm defaults to off; keep it for interactive installs - disable port hopping by default in menu "1. quick install" by dropping the 50000:51000 default, matching the -l path; an explicit --HY2_PORT_HOPPING_RANGE still enables it fix: 修复 BusyBox 上 UUID/订阅错值,统一快速安装默认行为 - UUID_CONFIRM 提取改用 awk -F '"' 字段抓取 conf JSON,nginx.conf 用 sed 抓订阅 / WS 路径段兜底,避开 BusyBox/Mawk 不兼容的量词正则,修复 -d 改 UUID 后订阅链接出现随机 UUID - -l / -K / 非交互安装默认 Realm 不启用,隐藏 Realm 与端口跳跃互斥提示;交互安装保留提示 - 菜单「1. 极速安装」去掉端口跳跃 50000:51000 默认值,改为默认关闭,与 -l 一致;显式传 --HY2_PORT_HOPPING_RANGE 仍可开启
1 parent 90a1dc0 commit e5d90df

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

sing-box.sh

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# 当前脚本版本号
4-
VERSION='v1.3.23 (2026.08.15)'
4+
VERSION='v1.3.23 (2026.08.17)'
55

66
# Github 反代加速代理
77
GITHUB_PROXY=('https://hub.glowp.xyz/' 'https://proxy.vvvv.ee/')
@@ -184,8 +184,8 @@ E[71]="Create shortcut [ sb ] successfully."
184184
C[71]="创建快捷 [ sb ] 指令成功!"
185185
E[72]="Path to each client configuration file: ${WORK_DIR}/subscribe/\n The full template can be found at:\n https://github.com/chika0801/sing-box-examples/tree/main/Tun"
186186
C[72]="各客户端配置文件路径: ${WORK_DIR}/subscribe/\n 完整模板可参照:\n https://github.com/chika0801/sing-box-examples/tree/main/Tun"
187-
E[73]=""
188-
C[73]=""
187+
E[73]="Common rule_set: openai / google / youtube / netflix / telegram / tiktok / twitter / claude / gemini\n Enter name will auto-prefix geosite- and validate existence"
188+
C[73]="常用规则集: openai / google / youtube / netflix / telegram / tiktok / twitter / claude / gemini\n 输入名称会自动补全 geosite- 前缀并校验是否存在"
189189
E[74]="Keep protocols"
190190
C[74]="保留协议"
191191
E[75]="Add protocols"
@@ -1554,6 +1554,7 @@ custom_route_add() {
15541554

15551555
elif [ "$RULE_TYPE" = "rule_set" ]; then
15561556
# 输入规则集名称
1557+
hint "\n $(text 73) \n"
15571558
reading " $(text 154) " RULESET_INPUT
15581559
[ -z "$RULESET_INPUT" ] && info " $(text 135) " && return
15591560

@@ -3074,8 +3075,8 @@ sing-box_variables() {
30743075
# 如选择有 c. hysteria2 时,先选择 Realm / WARP,再选择是否使用端口跳跃。
30753076
# 这三项属于 Hysteria2 子选项,不计入安装总步骤,也不显示步骤编号。
30763077
if [[ "${INSTALL_PROTOCOLS[@]}" =~ 'c' ]]; then
3077-
# Realm 与端口跳跃互斥:先提示;开启 Realm 后跳过端口跳跃交互
3078-
hint "\n $(text 186) \n"
3078+
# Realm 与端口跳跃互斥:仅交互式安装提示;快速 / 非交互安装默认不使用 Realm,无需提示
3079+
[[ "$NONINTERACTIVE_INSTALL" != 'noninteractive_install' && "$IS_FAST_INSTALL" != 'is_fast_install' ]] && hint "\n $(text 186) \n"
30793080
input_hy2_realm
30803081
local _SAVED_TOTAL_STEPS="$TOTAL_STEPS"
30813082
TOTAL_STEPS=''
@@ -4943,10 +4944,11 @@ fetch_nodes_value() {
49434944

49444945
# 获取 UUID_CONFIRM(从 JSON 配置文件读取,不依赖 nginx)
49454946
# 如 UUID_CONFIRM 已有值(例如上层已交互输入),跳过 JSON 读取,避免重复弹窗
4946-
[ -z "$UUID_CONFIRM" ] && UUID_CONFIRM=$(awk 'match($0, /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/) { print substr($0, RSTART, RLENGTH); exit }' ${WORK_DIR}/conf/1*.json 2>/dev/null)
4947-
# JSON 中提取不到时,尝试从 nginx.conf 提取(订阅开启 / 关闭时 nginx.conf 一定含有 UUID)
4947+
[ -z "$UUID_CONFIRM" ] && UUID_CONFIRM=$(awk -F '"' '/"uuid"[[:space:]]*:[[:space:]]*"/ || /"id"[[:space:]]*:[[:space:]]*"/ {print $4; exit}' ${WORK_DIR}/conf/1*.json 2>/dev/null)
4948+
# JSON 中提取不到时,尝试从 nginx.conf 提取订阅 / WS 路径段(订阅开启 / 关闭时 nginx.conf 一定含有 UUID;
4949+
# 用 sed 抓路径段而非 match 量词正则,兼容 BusyBox / mawk)
49484950
[ -z "$UUID_CONFIRM" ] && [ -s "${WORK_DIR}/nginx.conf" ] && \
4949-
UUID_CONFIRM=$(awk 'match($0, /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/) { print substr($0, RSTART, RLENGTH); exit }' ${WORK_DIR}/nginx.conf 2>/dev/null)
4951+
UUID_CONFIRM=$(sed -n 's#.*location ~ \^/\([^/]*\)/auto.*#\1#p; s#.*location /\([^/]*\)-vmess.*#\1#p; s#.*location /\([^/]*\)-vless.*#\1#p' ${WORK_DIR}/nginx.conf 2>/dev/null | sed -n '1p')
49504952
# 提取不到时,仅在安装相关流程走交互式输入;其余只读流程(如 sb -n 查看节点信息)用随机 UUID 兜底,避免无谓弹窗
49514953
# 说明:仅安装 shadowsocks / trojan / anytls / naive 等"凭证非 UUID 格式"协议时,以上提取必然为空,
49524954
# 此时导出节点信息不需要 UUID,不应阻塞用户交互
@@ -6406,7 +6408,7 @@ menu_setting() {
64066408
OPTION[8]="8. $(text 69)"
64076409
OPTION[9]="9. $(text 76)"
64086410

6409-
ACTION[1]() { IS_FAST_INSTALL='is_fast_install'; CHOOSE_PROTOCOLS=${CHOOSE_PROTOCOLS:-'a'}; START_PORT=${START_PORT:-"$START_PORT_DEFAULT"}; CDN=${CDN:-"${CDN_DOMAIN[0]}"}; IS_SUB='is_sub'; IS_ARGO='is_argo'; HY2_PORT_HOPPING_RANGE=${HY2_PORT_HOPPING_RANGE:-'50000:51000'}; install_sing-box; export_list install; create_shortcut; exit; }
6411+
ACTION[1]() { IS_FAST_INSTALL='is_fast_install'; CHOOSE_PROTOCOLS=${CHOOSE_PROTOCOLS:-'a'}; START_PORT=${START_PORT:-"$START_PORT_DEFAULT"}; CDN=${CDN:-"${CDN_DOMAIN[0]}"}; IS_SUB='is_sub'; IS_ARGO='is_argo'; install_sing-box; export_list install; create_shortcut; exit; }
64106412
ACTION[2]() { IS_SUB=is_sub; IS_ARGO=is_argo; install_sing-box; export_list install; create_shortcut; exit; }
64116413
ACTION[3]() { IS_SUB=no_sub; IS_ARGO=is_argo; install_sing-box; export_list install; create_shortcut; exit; }
64126414
ACTION[4]() { IS_SUB=is_sub; IS_ARGO=no_argo; install_sing-box; export_list install; create_shortcut; exit; }

0 commit comments

Comments
 (0)