luci-app-passwall: sync upstream

This commit is contained in:
actions 2024-03-31 22:30:04 +08:00
parent 08120a0662
commit e4cbc7d7c4
4 changed files with 58 additions and 22 deletions

View File

@ -56,10 +56,10 @@ o.rewrite_option = o.option
o = s:option(Value, option_name("hop_interval"), translate("Hop Interval")) o = s:option(Value, option_name("hop_interval"), translate("Hop Interval"))
o.rewrite_option = o.option o.rewrite_option = o.option
o = s:option(Value, option_name("recv_window_conn"), translate("QUIC stream receive window")) o = s:option(Value, option_name("recv_window_conn"), translate("QUIC connection receive window"))
o.rewrite_option = o.option o.rewrite_option = o.option
o = s:option(Value, option_name("recv_window"), translate("QUIC connection receive window")) o = s:option(Value, option_name("recv_window"), translate("QUIC stream receive window"))
o.rewrite_option = o.option o.rewrite_option = o.option
o = s:option(Value, option_name("idle_timeout"), translate("Idle Timeout")) o = s:option(Value, option_name("idle_timeout"), translate("Idle Timeout"))

View File

@ -94,6 +94,15 @@ o:value("leastPing")
o:value("leastLoad") o:value("leastLoad")
o.default = "leastLoad" o.default = "leastLoad"
-- Fallback Node
if api.compare_versions(api.get_app_version("xray"), ">=", "1.8.10") then
local o = s:option(ListValue, option_name("fallback_node"), translate("Fallback Node"))
o:depends({ [option_name("protocol")] = "_balancing" })
o:value("",translate("Null"))
o.default = ""
for k, v in pairs(nodes_table) do o:value(v.id, v.remark) end
end
-- 探测地址 -- 探测地址
local o = s:option(Flag, option_name("useCustomProbeUrl"), translate("Use Custome Probe URL"), translate("By default the built-in probe URL will be used, enable this option to use a custom probe URL.")) local o = s:option(Flag, option_name("useCustomProbeUrl"), translate("Use Custome Probe URL"), translate("By default the built-in probe URL will be used, enable this option to use a custom probe URL."))
o:depends({ [option_name("balancingStrategy")] = "leastPing" }) o:depends({ [option_name("balancingStrategy")] = "leastPing" })

View File

@ -646,6 +646,7 @@ function gen_config(var)
local function gen_balancer(_node, loopbackTag) local function gen_balancer(_node, loopbackTag)
local blc_nodes = _node.balancing_node local blc_nodes = _node.balancing_node
local fallback_node_id = _node.fallback_node
local length = #blc_nodes local length = #blc_nodes
local valid_nodes = {} local valid_nodes = {}
for i = 1, length do for i = 1, length do
@ -668,6 +669,27 @@ function gen_config(var)
end end
end end
end end
if fallback_node_id == "" then
fallback_node_id = nil
end
if fallback_node_id then
local is_new_node = true
for _, outbound in ipairs(outbounds) do
if outbound.tag == fallback_node_id then
is_new_node = false
break
end
end
if is_new_node then
local fallback_node = uci:get_all(appname, fallback_node_id)
local outbound = gen_outbound(flag, fallback_node, fallback_node_id, { fragment = xray_settings.fragment == "1" or nil })
if outbound then
table.insert(outbounds, outbound)
else
fallback_node_id = nil
end
end
end
local balancer, rule local balancer, rule
if #valid_nodes > 0 then if #valid_nodes > 0 then
@ -675,6 +697,7 @@ function gen_config(var)
balancer = { balancer = {
tag = balancerTag, tag = balancerTag,
selector = valid_nodes, selector = valid_nodes,
fallbackTag = fallback_node_id,
strategy = { type = _node.balancingStrategy or "random" } strategy = { type = _node.balancingStrategy or "random" }
} }
if _node.balancingStrategy == "leastPing" or _node.balancingStrategy == "leastLoad" then if _node.balancingStrategy == "leastPing" or _node.balancingStrategy == "leastLoad" then
@ -683,11 +706,11 @@ function gen_config(var)
subjectSelector = { "blc-" }, subjectSelector = { "blc-" },
probeUrl = _node.useCustomProbeUrl and _node.probeUrl or nil, probeUrl = _node.useCustomProbeUrl and _node.probeUrl or nil,
probeInterval = _node.probeInterval or "1m", probeInterval = _node.probeInterval or "1m",
enableConcurrency = node.type == "Xray" and true or nil --这里只判断顶层节点(分流总节点/单独的负载均衡节点)类型为Xray就可以启用并发 enableConcurrency = true
} }
end end
end end
if loopbackTag and loopbackTag ~= "" then if loopbackTag == nil or loopbackTag =="" then loopbackTag = _node[".name"] end
local inboundTag = loopbackTag .. "-in" local inboundTag = loopbackTag .. "-in"
table.insert(outbounds, { table.insert(outbounds, {
protocol = "loopback", protocol = "loopback",
@ -700,7 +723,6 @@ function gen_config(var)
balancerTag = balancerTag balancerTag = balancerTag
} }
end end
end
return balancer, rule return balancer, rule
end end
@ -891,9 +913,10 @@ function gen_config(var)
end end
end end
if is_new_balancer then if is_new_balancer then
local balancer = gen_balancer(_node) local balancer, rule = gen_balancer(_node)
if balancer then if balancer then
table.insert(balancers, balancer) table.insert(balancers, balancer)
table.insert(rules, rule)
rule_balancerTag = balancer.tag rule_balancerTag = balancer.tag
end end
end end
@ -1020,11 +1043,12 @@ function gen_config(var)
} }
elseif node.protocol == "_balancing" then elseif node.protocol == "_balancing" then
if node.balancing_node then if node.balancing_node then
local balancer = gen_balancer(node) local balancer, rule = gen_balancer(node)
routing = { routing = {
balancers = { balancer }, balancers = { balancer },
rules = { rules = {
{ type = "field", network = "tcp,udp", balancerTag = balancer.tag } { type = "field", network = "tcp,udp", balancerTag = balancer.tag },
rule
} }
} }
end end

View File

@ -388,6 +388,9 @@ msgstr "负载均衡"
msgid "Balancing Strategy" msgid "Balancing Strategy"
msgstr "负载均衡策略" msgstr "负载均衡策略"
msgid "Fallback Node"
msgstr "后备节点"
msgid "Use Custome Probe URL" msgid "Use Custome Probe URL"
msgstr "使用自定义探测网址" msgstr "使用自定义探测网址"