mirror of
https://github.com/xiaorouji/openwrt-passwall2.git
synced 2025-05-01 05:10:04 +08:00
luci: optimize subscribe code
This commit is contained in:
parent
eed167412f
commit
c3db09b9a4
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user