feat: prompt for Caddy fallback on port 443 regardless of port occupancy status
Main / build (push) Waiting to run

This commit is contained in:
2026-07-08 01:04:46 +08:00
parent 5309bf254b
commit fcdeee1249
+29 -21
View File
@@ -301,18 +301,22 @@ ask() {
msg "$is_err 请输入正确的端口, 可选(1-65535)" msg "$is_err 请输入正确的端口, 可选(1-65535)"
continue continue
} }
if [[ $(is_test port_used $REPLY) && $is_ask_set != 'door_port' ]]; then if [[ $REPLY == 443 && $is_caddy && ${is_new_protocol,,} =~ "reality" ]]; then
if [[ $REPLY == 443 && $is_caddy && ${is_new_protocol,,} =~ "reality" ]]; then msg "\n检测到你的系统已启用 Caddy。"
msg "\n检测到 443 端口已被 Caddy 占用。" msg "你可以选择启用 REALITY 回落分流功能,将非科学上网流量转发给本地 Caddy (4443 端口)。"
msg "你可以选择启用 REALITY 回落分流功能,将非科学上网流量转发给本地 Caddy (4443 端口)。" if [[ $(is_test port_used 443) ]]; then
msg "这需要你后续手动将 Caddyfile 中的默认 https 端口修改为 4443 并重启 Caddy。" msg "这需要自动或手动将 Caddyfile 中的默认 https 端口修改为 4443 并重启 Caddy。"
ask string is_enable_fallback "是否启用 Caddy 回落分流?(y/n):" else
if [[ $is_enable_fallback =~ ^[Yy]$ ]]; then msg "检测到 443 端口当前空闲(可能是已转移到了 4443 端口)。"
is_reality_fallback=1
export $is_ask_set=$REPLY
break
fi
fi fi
ask string is_enable_fallback "是否启用 Caddy 回落分流?(y/n):"
if [[ $is_enable_fallback =~ ^[Yy]$ ]]; then
is_reality_fallback=1
export $is_ask_set=$REPLY
break
fi
fi
if [[ $(is_test port_used $REPLY) && $is_ask_set != 'door_port' ]]; then
msg "$is_err 无法使用 ($REPLY) 端口." msg "$is_err 无法使用 ($REPLY) 端口."
continue continue
fi fi
@@ -966,17 +970,21 @@ add() {
[[ ! $(is_test port ${is_use_port}) ]] && { [[ ! $(is_test port ${is_use_port}) ]] && {
err "($is_use_port) 不是一个有效的端口. $is_err_tips" err "($is_use_port) 不是一个有效的端口. $is_err_tips"
} }
[[ $(is_test port_used $is_use_port) && ! $is_gen ]] && { if [[ $is_use_port == 443 && $is_caddy && ${is_new_protocol,,} =~ "reality" ]]; then
if [[ $is_use_port == 443 && $is_caddy && ${is_new_protocol,,} =~ "reality" ]]; then msg "\n检测到你的系统已启用 Caddy。"
msg "\n检测到 443 端口已被 Caddy 占用。" msg "你可以选择启用 REALITY 回落分流功能,将非科学上网流量转发给本地 Caddy (4443 端口)。"
msg "你可以选择启用 REALITY 回落分流功能,将非科学上网流量转发给本地 Caddy (4443 端口)。" if [[ $(is_test port_used 443) ]]; then
msg "这需要你后续手动将 Caddyfile 中的默认 https 端口修改为 4443 并重启 Caddy。" msg "这需要自动或手动将 Caddyfile 中的默认 https 端口修改为 4443 并重启 Caddy。"
ask string is_enable_fallback "是否启用 Caddy 回落分流?(y/n):" else
if [[ $is_enable_fallback =~ ^[Yy]$ ]]; then msg "检测到 443 端口当前空闲(可能是已转移到了 4443 端口)。"
is_reality_fallback=1
fi
fi fi
[[ ! $is_reality_fallback ]] && err "无法使用 ($is_use_port) 端口. $is_err_tips" ask string is_enable_fallback "是否启用 Caddy 回落分流?(y/n):"
if [[ $is_enable_fallback =~ ^[Yy]$ ]]; then
is_reality_fallback=1
fi
fi
[[ $(is_test port_used $is_use_port) && ! $is_gen && ! $is_reality_fallback ]] && {
err "无法使用 ($is_use_port) 端口. $is_err_tips"
} }
port=$is_use_port port=$is_use_port
fi fi