From 68c70b4a2505ed79fa275fa254100dff8ab3c1bb Mon Sep 17 00:00:00 2001 From: HA Date: Mon, 27 Apr 2026 13:49:09 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81ipv6=E8=BD=AC?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- realm/realm.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/realm/realm.sh b/realm/realm.sh index 5b62d71..8b0adb0 100644 --- a/realm/realm.sh +++ b/realm/realm.sh @@ -346,8 +346,8 @@ function add_rule() { echo -e "${RED}端口无效。${NC}" done - read -p "请输入本地监听地址 [默认 0.0.0.0]: " listen_addr - listen_addr="${listen_addr:-0.0.0.0}" + read -p "请输入本地监听地址 [默认 :: 同时监听 IPv4/IPv6]: " listen_addr + listen_addr="${listen_addr:-::}" while true; do read -p "请输入转发目标地址 (域名或 IP): " remote_host @@ -363,7 +363,12 @@ function add_rule() { echo -e "${RED}端口无效。${NC}" done - local listen="${listen_addr}:${listen_port}" + local listen + if [[ "$listen_addr" =~ : && ! "$listen_addr" =~ ^\[ ]]; then + listen="[${listen_addr}]:${listen_port}" + else + listen="${listen_addr}:${listen_port}" + fi local remote if [[ "$remote_host" =~ : && ! "$remote_host" =~ ^\[ ]]; then remote="[${remote_host}]:${remote_port}"