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
+15 -7
View File
@@ -301,11 +301,14 @@ 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检测到 443 端口已被 Caddy 占用。" msg "\n检测到你的系统已启用 Caddy。"
msg "你可以选择启用 REALITY 回落分流功能,将非科学上网流量转发给本地 Caddy (4443 端口)。" msg "你可以选择启用 REALITY 回落分流功能,将非科学上网流量转发给本地 Caddy (4443 端口)。"
msg "这需要你后续手动将 Caddyfile 中的默认 https 端口修改为 4443 并重启 Caddy。" if [[ $(is_test port_used 443) ]]; then
msg "这需要自动或手动将 Caddyfile 中的默认 https 端口修改为 4443 并重启 Caddy。"
else
msg "检测到 443 端口当前空闲(可能是已转移到了 4443 端口)。"
fi
ask string is_enable_fallback "是否启用 Caddy 回落分流?(y/n):" ask string is_enable_fallback "是否启用 Caddy 回落分流?(y/n):"
if [[ $is_enable_fallback =~ ^[Yy]$ ]]; then if [[ $is_enable_fallback =~ ^[Yy]$ ]]; then
is_reality_fallback=1 is_reality_fallback=1
@@ -313,6 +316,7 @@ ask() {
break break
fi fi
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检测到 443 端口已被 Caddy 占用。" msg "\n检测到你的系统已启用 Caddy。"
msg "你可以选择启用 REALITY 回落分流功能,将非科学上网流量转发给本地 Caddy (4443 端口)。" msg "你可以选择启用 REALITY 回落分流功能,将非科学上网流量转发给本地 Caddy (4443 端口)。"
msg "这需要你后续手动将 Caddyfile 中的默认 https 端口修改为 4443 并重启 Caddy。" if [[ $(is_test port_used 443) ]]; then
msg "这需要自动或手动将 Caddyfile 中的默认 https 端口修改为 4443 并重启 Caddy。"
else
msg "检测到 443 端口当前空闲(可能是已转移到了 4443 端口)。"
fi
ask string is_enable_fallback "是否启用 Caddy 回落分流?(y/n):" ask string is_enable_fallback "是否启用 Caddy 回落分流?(y/n):"
if [[ $is_enable_fallback =~ ^[Yy]$ ]]; then if [[ $is_enable_fallback =~ ^[Yy]$ ]]; then
is_reality_fallback=1 is_reality_fallback=1
fi fi
fi fi
[[ ! $is_reality_fallback ]] && err "无法使用 ($is_use_port) 端口. $is_err_tips" [[ $(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