luci: update subscribe script
This commit is contained in:
parent
3a065361bb
commit
f152d28d69
@ -121,6 +121,9 @@ do
|
|||||||
set = function(o, server)
|
set = function(o, server)
|
||||||
uci:set(appname, t[".name"], option, server)
|
uci:set(appname, t[".name"], option, server)
|
||||||
o.newNodeId = server
|
o.newNodeId = server
|
||||||
|
end,
|
||||||
|
delete = function(o)
|
||||||
|
uci:delete(appname, t[".name"])
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
@ -140,6 +143,9 @@ do
|
|||||||
set = function(o, server)
|
set = function(o, server)
|
||||||
uci:set(appname, t[".name"], option, server)
|
uci:set(appname, t[".name"], option, server)
|
||||||
o.newNodeId = server
|
o.newNodeId = server
|
||||||
|
end,
|
||||||
|
delete = function(o)
|
||||||
|
uci:delete(appname, t[".name"])
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
@ -228,16 +234,21 @@ do
|
|||||||
|
|
||||||
for k, e in pairs(rules) do
|
for k, e in pairs(rules) do
|
||||||
local _node_id = node[e[".name"]] or nil
|
local _node_id = node[e[".name"]] or nil
|
||||||
|
if _node_id and api.parseURL(_node_id) then
|
||||||
|
else
|
||||||
CONFIG[#CONFIG + 1] = {
|
CONFIG[#CONFIG + 1] = {
|
||||||
log = false,
|
log = false,
|
||||||
currentNode = _node_id and uci:get_all(appname, _node_id) or nil,
|
currentNode = _node_id and uci:get_all(appname, _node_id) or nil,
|
||||||
remarks = "分流" .. e.remarks .. "节点",
|
remarks = "分流" .. e.remarks .. "节点",
|
||||||
set = function(o, server)
|
set = function(o, server)
|
||||||
|
if not server then server = "nil" end
|
||||||
uci:set(appname, node_id, e[".name"], server)
|
uci:set(appname, node_id, e[".name"], server)
|
||||||
o.newNodeId = server
|
o.newNodeId = server
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
elseif node.protocol and node.protocol == '_balancing' then
|
elseif node.protocol and node.protocol == '_balancing' then
|
||||||
local node_id = node[".name"]
|
local node_id = node[".name"]
|
||||||
local nodes = {}
|
local nodes = {}
|
||||||
@ -288,7 +299,8 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if v.currentNode == nil then
|
if v.currentNode == nil and v.delete then
|
||||||
|
v.delete()
|
||||||
CONFIG[k] = nil
|
CONFIG[k] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -810,23 +822,13 @@ local function truncate_nodes(add_from)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function select_node(nodes, config)
|
local function select_node(nodes, config)
|
||||||
local server
|
|
||||||
if config.currentNode then
|
if config.currentNode then
|
||||||
-- 特别优先级 分流 + 备注
|
local server
|
||||||
if config.currentNode.protocol and config.currentNode.protocol == '_shunt' then
|
-- 特别优先级 cfgid
|
||||||
|
if config.currentNode[".name"] then
|
||||||
for index, node in pairs(nodes) do
|
for index, node in pairs(nodes) do
|
||||||
if node.remarks == config.currentNode.remarks then
|
if node[".name"] == config.currentNode[".name"] then
|
||||||
log('更新【' .. config.remarks .. '】分流匹配节点:' .. node.remarks)
|
log('更新【' .. config.remarks .. '】匹配节点:' .. node.remarks)
|
||||||
server = node[".name"]
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- 特别优先级 负载均衡 + 备注
|
|
||||||
if config.currentNode.protocol and config.currentNode.protocol == '_balancing' then
|
|
||||||
for index, node in pairs(nodes) do
|
|
||||||
if node.remarks == config.currentNode.remarks then
|
|
||||||
log('更新【' .. config.remarks .. '】负载均衡匹配节点:' .. node.remarks)
|
|
||||||
server = node[".name"]
|
server = node[".name"]
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
@ -912,7 +914,6 @@ local function select_node(nodes, config)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
-- 还不行 随便找一个
|
-- 还不行 随便找一个
|
||||||
if not server then
|
if not server then
|
||||||
local nodes_table = {}
|
local nodes_table = {}
|
||||||
@ -931,6 +932,9 @@ local function select_node(nodes, config)
|
|||||||
if server then
|
if server then
|
||||||
config.set(config, server)
|
config.set(config, server)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
config.set(config, nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update_node(manual)
|
local function update_node(manual)
|
||||||
|
Loading…
Reference in New Issue
Block a user