diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile
index 0970643f0..695d8f149 100644
--- a/luci-app-passwall/Makefile
+++ b/luci-app-passwall/Makefile
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=4.63
-PKG_RELEASE:=3
+PKG_RELEASE:=4
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \
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 300b7eee9..9d93c4000 100644
--- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
+++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua
@@ -84,21 +84,39 @@ s:tab("Main", translate("Main"))
o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
o.rmempty = false
----- TCP Node
-tcp_node = s:taboption("Main", ListValue, "tcp_node", "" .. translate("TCP Node") .. "")
-tcp_node.description = ""
-local current_node = luci.sys.exec(string.format("[ -f '/tmp/etc/%s/id/TCP' ] && echo -n $(cat /tmp/etc/%s/id/TCP)", appname, appname))
-if current_node and current_node ~= "" and current_node ~= "nil" then
- local n = uci:get_all(appname, current_node)
+local auto_switch_tip
+local auto_switch_flag
+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
- local remarks = api.get_full_node_remarks(n)
- local url = api.url("node_config", current_node)
- tcp_node.description = tcp_node.description .. translatef("Current node: %s", string.format('%s', url, remarks)) .. "
"
+ 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)
+ 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)) .. "
"
end
end
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
+ tcp_node.description = auto_switch_tip
+end
---- UDP Node
udp_node = s:taboption("Main", ListValue, "udp_node", "" .. translate("UDP Node") .. "")
@@ -145,12 +163,14 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then
end
type.cfgvalue = get_cfgvalue(v.id, "type")
type.write = get_write(v.id, "type")
+
-- pre-proxy
o = s:taboption("Main", Flag, vid .. "-preproxy_enabled", translate("Preproxy"))
o:depends("tcp_node", v.id)
o.rmempty = false
o.cfgvalue = get_cfgvalue(v.id, "preproxy_enabled")
o.write = get_write(v.id, "preproxy_enabled")
+
o = s:taboption("Main", ListValue, vid .. "-main_node", string.format('%s', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including Default
) has a separate switch that controls whether this rule uses the pre-proxy or not."))
o:depends(vid .. "-preproxy_enabled", "1")
for k1, v1 in pairs(balancing_list) do
@@ -161,6 +181,10 @@ 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
+ o.description = auto_switch_tip
+ end
+
if (has_v2ray and has_xray) or (v.type == "V2ray" and not has_v2ray) or (v.type == "Xray" and not has_xray) then
type:depends("tcp_node", v.id)
else
@@ -209,6 +233,9 @@ 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
+ o.description = auto_switch_tip
+ end
local id = "default_proxy_tag"
o = s:taboption("Main", ListValue, vid .. "-" .. id, string.format('* %s', translate("Default Preproxy")), translate("When using, localhost will connect this node first and then use this node to connect the default node."))
diff --git a/luci-app-passwall/luasrc/passwall/api.lua b/luci-app-passwall/luasrc/passwall/api.lua
index 6f44644ca..19ceeeb83 100644
--- a/luci-app-passwall/luasrc/passwall/api.lua
+++ b/luci-app-passwall/luasrc/passwall/api.lua
@@ -322,7 +322,7 @@ function get_valid_nodes()
return nodes
end
-function get_full_node_remarks(n)
+function get_node_remarks(n)
local remarks = ""
if n then
if n.protocol and (n.protocol == "_balancing" or n.protocol == "_shunt" or n.protocol == "_iface") then
@@ -340,7 +340,17 @@ function get_full_node_remarks(n)
end
type2 = type2 .. " " .. protocol
end
- remarks = "%s:[%s] %s:%s" % {type2, n.remarks, n.address, n.port}
+ remarks = "%s:[%s]" % {type2, n.remarks}
+ end
+ end
+ return remarks
+end
+
+function get_full_node_remarks(n)
+ local remarks = get_node_remarks(n)
+ if #remarks > 0 then
+ if n.address and n.port then
+ remarks = remarks .. " " .. n.address .. ":" .. n.port
end
end
return remarks
diff --git a/luci-app-passwall/root/usr/share/passwall/app.sh b/luci-app-passwall/root/usr/share/passwall/app.sh
index 9028a5d1f..ef83342d1 100755
--- a/luci-app-passwall/root/usr/share/passwall/app.sh
+++ b/luci-app-passwall/root/usr/share/passwall/app.sh
@@ -896,8 +896,8 @@ node_switch() {
echo $new_node > $TMP_ID_PATH/${FLAG}
[ "$shunt_logic" != "0" ] && [ "$(config_n_get $new_node protocol nil)" = "_shunt" ] && {
- echo $(config_n_get $new_node default_node nil) > $TMP_ID_PATH/${1}_default
- echo $(config_n_get $new_node main_node nil) > $TMP_ID_PATH/${1}_main
+ echo $(config_n_get $new_node default_node nil) > $TMP_ID_PATH/${FLAG}_default
+ echo $(config_n_get $new_node main_node nil) > $TMP_ID_PATH/${FLAG}_main
uci commit $CONFIG
}