luci-app-passwall: sync upstream

last commit: a3f4f1a16c
This commit is contained in:
gitea-action 2025-04-23 17:30:26 +08:00
parent 9111e3e4f9
commit b04fbad043
3 changed files with 11 additions and 40 deletions

View File

@ -14,7 +14,6 @@ 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"
@ -24,24 +23,6 @@ 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.node_type == "normal" 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")
@ -168,17 +149,13 @@ 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 type = m:get(n, "type") or "" local result = "---"
local protocol = m:get(n, "protocol") or ""
if (type == "sing-box" or type == "Xray") and
(protocol == "_shunt" or protocol == "_balancing" or protocol == "_urltest" or protocol == "_iface") then
return string.format('<span class="ping_value" cbiid="%s">---</span>', n)
end
if auto_detection_time ~= "icmp" then 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")) result = string.format('<span class="ping"><a href="javascript:void(0)" onclick="javascript:ping_node(\'%s\', this, \'icmp\')">%s</a></span>', n, translate("Test"))
else else
return string.format('<span class="ping_value" cbiid="%s">---</span>', n) result = string.format('<span class="ping_value" cbiid="%s">---</span>', n)
end end
return result
end end
---- TCP Ping ---- TCP Ping
@ -186,17 +163,13 @@ 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 type = m:get(n, "type") or "" local result = "---"
local protocol = m:get(n, "protocol") or ""
if (type == "sing-box" or type == "Xray") and
(protocol == "_shunt" or protocol == "_balancing" or protocol == "_urltest" or protocol == "_iface") then
return string.format('<span class="tcping_value" cbiid="%s">---</span>', n)
end
if auto_detection_time ~= "tcping" then 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")) result = string.format('<span class="ping"><a href="javascript:void(0)" onclick="javascript:ping_node(\'%s\', this, \'tcping\')">%s</a></span>', n, translate("Test"))
else else
return string.format('<span class="tcping_value" cbiid="%s">---</span>', n) result = 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,7 +46,8 @@ 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;
@ -313,7 +314,7 @@ table td, .table .td {
/* 自动Ping */ /* 自动Ping */
function pingAllNodes() { function pingAllNodes() {
if (window.auto_detection_time == "icmp" || window.auto_detection_time == "tcping") { if (auto_detection_time == "icmp" || 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

@ -634,9 +634,6 @@ 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 "显示服务器地址和端口"