diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile
index fe78fc951..bd8d99663 100644
--- a/luci-app-passwall/Makefile
+++ b/luci-app-passwall/Makefile
@@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
-PKG_VERSION:=4.64-1
+PKG_VERSION:=4.64-4
PKG_RELEASE:=
PKG_CONFIG_DEPENDS:= \
diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
index 6a7b9c3e5..cc5a89451 100644
--- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
+++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
@@ -85,28 +85,31 @@ o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
o.rmempty = false
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))
if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then
local n = uci:get_all(appname, current_tcp_node)
if n then
if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then
- auto_switch_flag = ""
if n.protocol == "_shunt" then
local shunt_logic = tonumber(m:get("@auto_switch[0]", "shunt_logic"))
- if shunt_logic == 1 then
- auto_switch_flag = "default"
- elseif shunt_logic == 2 then
- auto_switch_flag = "main"
- end
- 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))
- if current_tcp_node and current_tcp_node ~= "" and current_tcp_node ~= "nil" then
- n = uci:get_all(appname, current_tcp_node)
+ if shunt_logic == 1 or shunt_logic == 2 then
+ if shunt_logic == 1 then
+ shunt_remark = "default"
+ elseif shunt_logic == 2 then
+ shunt_remark = "main"
+ end
+ 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))
+ 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
- local remarks = api.get_node_remarks(n)
- local url = api.url("node_config", n[".name"])
- auto_switch_tip = translatef("Current node: %s", string.format('%s', url, remarks)) .. "
"
+ if n then
+ local remarks = api.get_node_remarks(n)
+ local url = api.url("node_config", n[".name"])
+ auto_switch_tip = translatef("Current node: %s", string.format('%s', url, remarks)) .. "
"
+ end
end
end
end
@@ -114,7 +117,7 @@ end
---- TCP Node
tcp_node = s:taboption("Main", ListValue, "tcp_node", "" .. translate("TCP Node") .. "")
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
end
@@ -181,7 +184,7 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then
end
o.cfgvalue = get_cfgvalue(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
end
@@ -233,7 +236,7 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then
for k1, v1 in pairs(normal_list) do
o:value(v1.id, v1.remark)
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
end