diff --git a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua index 48c3b93..3b081e4 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua +++ b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua @@ -182,6 +182,11 @@ do if true then local i = 0 local option = "lbss" + local function is_ip_port(str) + if type(str) ~= "string" then return false end + local ip, port = str:match("^([%d%.]+):(%d+)$") + return ip and datatypes.ipaddr(ip) and tonumber(port) and tonumber(port) <= 65535 + end uci:foreach(appname, "haproxy_config", function(t) i = i + 1 local node_id = t[option] @@ -191,11 +196,17 @@ do remarks = "HAProxy负载均衡节点列表[" .. i .. "]", currentNode = node_id and uci:get_all(appname, node_id) or nil, set = function(o, server) - uci:set(appname, t[".name"], option, server) - o.newNodeId = server + -- 如果当前 lbss 值不是 ip:port 格式,才进行修改 + if not is_ip_port(t[option]) then + uci:set(appname, t[".name"], option, server) + o.newNodeId = server + end end, delete = function(o) - uci:delete(appname, t[".name"]) + -- 如果当前 lbss 值不是 ip:port 格式,才进行删除 + if not is_ip_port(t[option]) then + uci:delete(appname, t[".name"]) + end end } end)