From 9cf6ba7bb01463c914fd47e081a5fc27585de75b Mon Sep 17 00:00:00 2001 From: gitea-action Date: Sat, 29 Mar 2025 13:00:23 +0800 Subject: [PATCH] luci-app-passwall: sync upstream last commit: https://github.com/xiaorouji/openwrt-passwall/commit/dae13c86a4cb79a37217ed3f92171434a654c085 --- .../model/cbi/passwall/client/type/ray.lua | 15 +++++++-- .../luasrc/passwall/util_xray.lua | 33 ++++++++++++++----- luci-app-passwall/po/zh-cn/passwall.po | 14 +++++--- 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua index 488974ff7..325673ef8 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua @@ -95,7 +95,7 @@ m.uci:foreach(appname, "socks", function(s) end) -- 负载均衡列表 -local o = s:option(DynamicList, _n("balancing_node"), translate("Load balancing node list"), translate("Load balancing node list, document")) +local o = s:option(DynamicList, _n("balancing_node"), translate("Load balancing node list"), translate("Load balancing node list, document")) o:depends({ [_n("protocol")] = "_balancing" }) for k, v in pairs(nodes_table) do o:value(v.id, v.remark) end @@ -104,7 +104,8 @@ o:depends({ [_n("protocol")] = "_balancing" }) o:value("random") o:value("roundRobin") o:value("leastPing") -o.default = "leastPing" +o:value("leastLoad") +o.default = "leastLoad" -- Fallback Node if api.compare_versions(xray_version, ">=", "1.8.10") then @@ -133,6 +134,7 @@ end -- 探测地址 local ucpu = s:option(Flag, _n("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.")) ucpu:depends({ [_n("balancingStrategy")] = "leastPing" }) +ucpu:depends({ [_n("balancingStrategy")] = "leastLoad" }) local pu = s:option(Value, _n("probeUrl"), translate("Probe URL")) pu:depends({ [_n("useCustomProbeUrl")] = true }) @@ -148,8 +150,9 @@ pu.description = translate("The URL used to detect the connection status.") -- 探测间隔 local pi = s:option(Value, _n("probeInterval"), translate("Probe Interval")) pi:depends({ [_n("balancingStrategy")] = "leastPing" }) +pi:depends({ [_n("balancingStrategy")] = "leastLoad" }) pi.default = "1m" -pi.description = translate("The interval between initiating probes. Every time this time elapses, a server status check is performed on a server. The time format is numbers + units, such as '10s', '2h45m', and the supported time units are ns, us, ms, s, m, h, which correspond to nanoseconds, microseconds, milliseconds, seconds, minutes, and hours, respectively.") +pi.description = translate("The interval between initiating probes. The time format is numbers + units, such as '10s', '2h45m', and the supported time units are ns, us, ms, s, m, h, which correspond to nanoseconds, microseconds, milliseconds, seconds, minutes, and hours, respectively.") if api.compare_versions(xray_version, ">=", "1.8.12") then ucpu:depends({ [_n("protocol")] = "_balancing" }) @@ -159,6 +162,12 @@ else pi:depends({ [_n("balancingStrategy")] = "leastPing" }) end +o = s:option(Value, _n("expected"), translate("Preferred Node Count")) +o:depends({ [_n("balancingStrategy")] = "leastLoad" }) +o.datatype = "uinteger" +o.default = "2" +o.description = translate("The load balancer selects the optimal number of nodes, and traffic is randomly distributed among them.") + -- [[ 分流模块 ]] if #nodes_table > 0 then diff --git a/luci-app-passwall/luasrc/passwall/util_xray.lua b/luci-app-passwall/luasrc/passwall/util_xray.lua index 1e7f3dcff..d1052d4cd 100644 --- a/luci-app-passwall/luasrc/passwall/util_xray.lua +++ b/luci-app-passwall/luasrc/passwall/util_xray.lua @@ -581,7 +581,8 @@ function gen_config(var) local dns = nil local fakedns = nil local routing = nil - local observatory = nil + local burstObservatory = nil + local strategy = nil local inbounds = {} local outbounds = {} local COMMON = {} @@ -761,19 +762,33 @@ function gen_config(var) end end end + if _node.balancingStrategy == "leastLoad" then + strategy = { + type = _node.balancingStrategy, + settings = { + expected = _node.expected and tonumber(_node.expected) and tonumber(_node.expected) or 2, + maxRTT = "1s" + } + } + else + strategy = { type = _node.balancingStrategy or "random" } + end table.insert(balancers, { tag = balancer_tag, selector = valid_nodes, fallbackTag = fallback_node_tag, - strategy = { type = _node.balancingStrategy or "random" } + strategy = strategy }) - if _node.balancingStrategy == "leastPing" or fallback_node_tag then - if not observatory then - observatory = { + if _node.balancingStrategy == "leastPing" or _node.balancingStrategy == "leastLoad" or fallback_node_tag then + if not burstObservatory then + burstObservatory = { subjectSelector = { "blc-" }, - probeUrl = _node.useCustomProbeUrl and _node.probeUrl or nil, - probeInterval = _node.probeInterval or "1m", - enableConcurrency = true + pingConfig = { + destination = _node.useCustomProbeUrl and _node.probeUrl or nil, + interval = _node.probeInterval or "1m", + sampling = 3, + timeout = "5s" + } } end end @@ -1358,7 +1373,7 @@ function gen_config(var) -- 传出连接 outbounds = outbounds, -- 连接观测 - observatory = observatory, + burstObservatory = burstObservatory, -- 路由 routing = routing, -- 本地策略 diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index 2925a998b..9b51c09f3 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -445,8 +445,14 @@ msgstr "用于检测连接状态的网址。" msgid "Probe Interval" msgstr "探测间隔" -msgid "The interval between initiating probes. Every time this time elapses, a server status check is performed on a server. The time format is numbers + units, such as '10s', '2h45m', and the supported time units are ns, us, ms, s, m, h, which correspond to nanoseconds, microseconds, milliseconds, seconds, minutes, and hours, respectively." -msgstr "发起探测的间隔。每经过这个时间,就会对一个服务器进行服务器状态检测。时间格式为数字+单位,比如"10s", "2h45m",支持的时间单位有 nsusmssmh,分别对应纳秒、微秒、毫秒、秒、分、时。" +msgid "The interval between initiating probes. The time format is numbers + units, such as '10s', '2h45m', and the supported time units are ns, us, ms, s, m, h, which correspond to nanoseconds, microseconds, milliseconds, seconds, minutes, and hours, respectively." +msgstr "发起探测的间隔。时间格式为数字+单位,比如"10s", "2h45m",支持的时间单位有 nsusmssmh,分别对应纳秒、微秒、毫秒、秒、分、时。" + +msgid "Preferred Node Count" +msgstr "优选节点数量" + +msgid "The load balancer selects the optimal number of nodes, and traffic is randomly distributed among them." +msgstr "负载均衡器选出最优节点的个数,流量将在这几个节点中随机分配。" msgid "Shunt" msgstr "分流" @@ -508,8 +514,8 @@ msgstr "仅 IPv6" msgid "Load balancing node list" msgstr "负载均衡节点列表" -msgid "Load balancing node list, document" -msgstr "负载均衡节点列表,文档原理" +msgid "Load balancing node list, document" +msgstr "负载均衡节点列表,文档原理" msgid "From Share URL" msgstr "导入分享URL"