luci-app-passwall: sync upstream

last commit: 0e0d730938
This commit is contained in:
gitea-action 2025-04-13 02:00:29 +08:00
parent fb58d8ed2a
commit c986d711f8
3 changed files with 40 additions and 15 deletions

View File

@ -14,6 +14,7 @@ o = s:option(ListValue, "auto_detection_time", translate("Automatic detection de
o:value("0", translate("Close")) o:value("0", translate("Close"))
o:value("icmp", "Ping") o:value("icmp", "Ping")
o:value("tcping", "TCP Ping") o:value("tcping", "TCP Ping")
o.description = translate("To optimize performance, auto-detection is disabled when there are more than 30 nodes.")
o = s:option(Flag, "show_node_info", translate("Show server address and port")) o = s:option(Flag, "show_node_info", translate("Show server address and port"))
o.default = "0" o.default = "0"
@ -23,6 +24,24 @@ s:append(Template(appname .. "/node_list/link_add_node"))
local auto_detection_time = m:get("@global_other[0]", "auto_detection_time") or "0" local auto_detection_time = m:get("@global_other[0]", "auto_detection_time") or "0"
local show_node_info = m:get("@global_other[0]", "show_node_info") or "0" local show_node_info = m:get("@global_other[0]", "show_node_info") or "0"
if auto_detection_time ~= "0" then
local node_count = 0
for k, e in ipairs(api.get_valid_nodes()) do
if e.protocol ~= "_shunt" and e.protocol ~= "_balancing" and e.protocol ~= "_urltest" and e.protocol ~= "_iface" then
node_count = node_count + 1
end
end
if node_count > 30 then auto_detection_time = "0" end
end
-- Pass the auto_detection_time global variable to the webpage
local o = s:option(DummyValue, "_auto_detection_time")
o.rawhtml = true
o.default = string.format([[
<script>
window.auto_detection_time = "%s";
</script>
]], auto_detection_time)
-- [[ Node List ]]-- -- [[ Node List ]]--
s = m:section(TypedSection, "nodes") s = m:section(TypedSection, "nodes")
@ -149,13 +168,15 @@ o = s:option(DummyValue, "ping", "Ping")
o.width = "8%" o.width = "8%"
o.rawhtml = true o.rawhtml = true
o.cfgvalue = function(t, n) o.cfgvalue = function(t, n)
local result = "---" local protocol = m:get(n, "protocol")
if auto_detection_time ~= "icmp" then if protocol == "_shunt" or protocol == "_balancing" or protocol == "_urltest" or protocol == "_iface" then
result = string.format('<span class="ping"><a href="javascript:void(0)" onclick="javascript:ping_node(\'%s\', this, \'icmp\')">%s</a></span>', n, translate("Test")) return string.format('<span class="ping_value" cbiid="%s">---</span>', n)
else end
result = string.format('<span class="ping_value" cbiid="%s">---</span>', n) if auto_detection_time ~= "icmp" then
return string.format('<span class="ping"><a href="javascript:void(0)" onclick="javascript:ping_node(\'%s\', this, \'icmp\')">%s</a></span>', n, translate("Test"))
else
return string.format('<span class="ping_value" cbiid="%s">---</span>', n)
end end
return result
end end
---- TCP Ping ---- TCP Ping
@ -163,13 +184,15 @@ o = s:option(DummyValue, "tcping", "TCPing")
o.width = "8%" o.width = "8%"
o.rawhtml = true o.rawhtml = true
o.cfgvalue = function(t, n) o.cfgvalue = function(t, n)
local result = "---" local protocol = m:get(n, "protocol")
if auto_detection_time ~= "tcping" then if protocol == "_shunt" or protocol == "_balancing" or protocol == "_urltest" or protocol == "_iface" then
result = string.format('<span class="ping"><a href="javascript:void(0)" onclick="javascript:ping_node(\'%s\', this, \'tcping\')">%s</a></span>', n, translate("Test")) return string.format('<span class="tcping_value" cbiid="%s">---</span>', n)
else end
result = string.format('<span class="tcping_value" cbiid="%s">---</span>', n) if auto_detection_time ~= "tcping" then
return string.format('<span class="ping"><a href="javascript:void(0)" onclick="javascript:ping_node(\'%s\', this, \'tcping\')">%s</a></span>', n, translate("Test"))
else
return string.format('<span class="tcping_value" cbiid="%s">---</span>', n)
end end
return result
end end
o = s:option(DummyValue, "_url_test", translate("URL Test")) o = s:option(DummyValue, "_url_test", translate("URL Test"))

View File

@ -46,8 +46,7 @@ table td, .table .td {
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
let auto_detection_time = "<%=api.uci_get_type("@global_other[0]", "auto_detection_time", "0")%>"
var node_list = {}; var node_list = {};
var node_count = 0; var node_count = 0;
@ -314,7 +313,7 @@ table td, .table .td {
/* 自动Ping */ /* 自动Ping */
function pingAllNodes() { function pingAllNodes() {
if (auto_detection_time == "icmp" || auto_detection_time == "tcping") { if (window.auto_detection_time == "icmp" || window.auto_detection_time == "tcping") {
var nodes = []; var nodes = [];
const ping_value = document.getElementsByClassName(auto_detection_time == "tcping" ? 'tcping_value' : 'ping_value'); const ping_value = document.getElementsByClassName(auto_detection_time == "tcping" ? 'tcping_value' : 'ping_value');
for (var i = 0; i < ping_value.length; i++) { for (var i = 0; i < ping_value.length; i++) {

View File

@ -628,6 +628,9 @@ msgstr "延迟"
msgid "Automatic detection delay" msgid "Automatic detection delay"
msgstr "自动检测延迟" msgstr "自动检测延迟"
msgid "To optimize performance, auto-detection is disabled when there are more than 30 nodes."
msgstr "为优化性能,超过 30 个节点不自动检测。"
msgid "Show server address and port" msgid "Show server address and port"
msgstr "显示服务器地址和端口" msgstr "显示服务器地址和端口"