From 1bbdeb3132d5f4777552da6dac265b2c881197c8 Mon Sep 17 00:00:00 2001 From: "IAN.Z" <1274803758@qq.com> Date: Fri, 26 Dec 2025 12:35:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20cluster=20=E6=94=AF=E6=8C=81ipv6?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E5=AD=97=E7=AC=A6=E4=B8=B2=20(#2124)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: zhuyin.zhu --- lualib/skynet/socket.lua | 3 ++- service/clusterd.lua | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lualib/skynet/socket.lua b/lualib/skynet/socket.lua index b4c0fb27..84f64b2b 100644 --- a/lualib/skynet/socket.lua +++ b/lualib/skynet/socket.lua @@ -408,7 +408,8 @@ end function socket.listen(host, port, backlog) if port == nil then - host, port = string.match(host, "([^:]+):(.+)$") + host, port = string.match(host, "(.+):([^:]+)$") + host = host:match("^%[(.-)%]$") or host port = tonumber(port) end local id = driver.listen(host, port, backlog) diff --git a/service/clusterd.lua b/service/clusterd.lua index ae410601..a1d8a2b5 100644 --- a/service/clusterd.lua +++ b/service/clusterd.lua @@ -39,7 +39,8 @@ local function open_channel(t, key) end local succ, err, c if address then - local host, port = string.match(address, "([^:]+):(.*)$") + local host, port = string.match(address, "(.+):([^:]+)$") + host = host:match("^%[(.-)%]$") or host c = node_sender[key] if c == nil then c = skynet.newservice("clustersender", key, nodename, host, port) @@ -147,6 +148,7 @@ function command.listen(source, addr, port, maxclient) if port == nil then local address = assert(node_address[addr], addr .. " is down") addr, port = string.match(address, "(.+):([^:]+)$") + addr = addr:match("^%[(.-)%]$") or addr port = tonumber(port) assert(port ~= 0) skynet.call(gate, "lua", "open", { address = addr, port = port, maxclient = maxclient })