luci: fix maybe wrong issue

This commit is contained in:
xiaorouji 2023-04-15 21:29:34 +08:00 committed by sbwml
parent dc8eb4f957
commit aa62fdcc18
2 changed files with 20 additions and 17 deletions

View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall PKG_NAME:=luci-app-passwall
PKG_VERSION:=4.64-1 PKG_VERSION:=4.64-4
PKG_RELEASE:= PKG_RELEASE:=
PKG_CONFIG_DEPENDS:= \ PKG_CONFIG_DEPENDS:= \

View File

@ -85,28 +85,31 @@ o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
o.rmempty = false o.rmempty = false
local auto_switch_tip local auto_switch_tip
local auto_switch_flag local shunt_remark
local current_tcp_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/TCP' ] && echo -n $(cat /tmp/etc/%s/id/TCP)", appname, appname)) local current_tcp_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/TCP' ] && echo -n $(cat /tmp/etc/%s/id/TCP)", appname, appname))
if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then
local n = uci:get_all(appname, current_tcp_node) local n = uci:get_all(appname, current_tcp_node)
if n then if n then
if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then
auto_switch_flag = ""
if n.protocol == "_shunt" then if n.protocol == "_shunt" then
local shunt_logic = tonumber(m:get("@auto_switch[0]", "shunt_logic")) local shunt_logic = tonumber(m:get("@auto_switch[0]", "shunt_logic"))
if shunt_logic == 1 then if shunt_logic == 1 or shunt_logic == 2 then
auto_switch_flag = "default" if shunt_logic == 1 then
elseif shunt_logic == 2 then shunt_remark = "default"
auto_switch_flag = "main" elseif shunt_logic == 2 then
end shunt_remark = "main"
current_tcp_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/TCP_%s' ] && echo -n $(cat /tmp/etc/%s/id/TCP_%s)", appname, auto_switch_flag, appname, auto_switch_flag)) end
if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then current_tcp_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/TCP_%s' ] && echo -n $(cat /tmp/etc/%s/id/TCP_%s)", appname, shunt_remark, appname, shunt_remark))
n = uci:get_all(appname, current_tcp_node) if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then
n = uci:get_all(appname, current_tcp_node)
end
end end
end end
local remarks = api.get_node_remarks(n) if n then
local url = api.url("node_config", n[".name"]) local remarks = api.get_node_remarks(n)
auto_switch_tip = translatef("Current node: %s", string.format('<a href="%s">%s</a>', url, remarks)) .. "<br />" local url = api.url("node_config", n[".name"])
auto_switch_tip = translatef("Current node: %s", string.format('<a href="%s">%s</a>', url, remarks)) .. "<br />"
end
end end
end end
end end
@ -114,7 +117,7 @@ end
---- TCP Node ---- TCP Node
tcp_node = s:taboption("Main", ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>") tcp_node = s:taboption("Main", ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>")
tcp_node:value("nil", translate("Close")) tcp_node:value("nil", translate("Close"))
if auto_switch_flag == "" and auto_switch_tip then if not shunt_remark and auto_switch_tip then
tcp_node.description = auto_switch_tip tcp_node.description = auto_switch_tip
end end
@ -181,7 +184,7 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then
end end
o.cfgvalue = get_cfgvalue(v.id, "main_node") o.cfgvalue = get_cfgvalue(v.id, "main_node")
o.write = get_write(v.id, "main_node") o.write = get_write(v.id, "main_node")
if auto_switch_flag == "main" and auto_switch_tip then if shunt_remark == "main" and auto_switch_tip then
o.description = auto_switch_tip o.description = auto_switch_tip
end end
@ -233,7 +236,7 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then
for k1, v1 in pairs(normal_list) do for k1, v1 in pairs(normal_list) do
o:value(v1.id, v1.remark) o:value(v1.id, v1.remark)
end end
if auto_switch_flag == "default" and auto_switch_tip then if shunt_remark == "default" and auto_switch_tip then
o.description = auto_switch_tip o.description = auto_switch_tip
end end