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 64a526f32..6ab0a01a3 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -146,10 +146,17 @@ 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 node - 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.")) + -- pre-proxy + o = s:taboption("Main", Flag, vid .. "-preproxy_enabled", translate("Preproxy")) o:depends("tcp_node", v.id) - o:value("nil", translate("Close")) + 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 + o:value(v1.id, v1.remark) + end for k1, v1 in pairs(normal_list) do o:value(v1.id, v1.remark) end @@ -158,18 +165,18 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then -- Xray dialerProxy local dialerProxy = s:taboption("Main", Flag, vid .. "-dialerProxy", translate("dialerProxy")) dialerProxy.default = "0" - dialerProxy:depends(vid .. "-type", "Xray") + dialerProxy.cfgvalue = get_cfgvalue(v.id, "dialerProxy") + dialerProxy.write = get_write(v.id, "dialerProxy") + dialerProxy.rmempty = false + dialerProxy:depends({ [vid .. "-type"] = "Xray", [vid .. "-preproxy_enabled"] = "1" }) 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 type:depends("tcp_node", "hide") --不存在的依赖,即始终隐藏 if v.type == "Xray" then - dialerProxy:depends("tcp_node", v.id) + dialerProxy:depends({ tcp_node = v.id, [vid .. "-preproxy_enabled"] = "1" }) end end - dialerProxy.cfgvalue = get_cfgvalue(v.id, "dialerProxy") - dialerProxy.write = get_write(v.id, "dialerProxy") - dialerProxy.rmempty = false uci:foreach(appname, "shunt_rules", function(e) local id = e[".name"] @@ -190,7 +197,7 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then end for k1, v1 in pairs(normal_list) do o:value(v1.id, v1.remark) - pt:depends(node_option, v1.id) + pt:depends({ [node_option] = v1.id, [vid .. "-preproxy_enabled"] = "1" }) end o.cfgvalue = get_cfgvalue(v.id, id) o.write = get_write(v.id, id) @@ -212,9 +219,12 @@ if (has_v2ray or has_xray) and #nodes_table > 0 then 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.")) + for k1, v1 in pairs(balancing_list) do + o:value(v1.id, v1.remark) + end for k1, v1 in pairs(normal_list) do if v1.protocol ~= "_balancing" then - o:depends(vid .. "-default_node", v1.id) + o:depends({ [vid .. "-default_node"] = v1.id, [vid .. "-preproxy_enabled"] = "1" }) end end o:value("nil", translate("Close")) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua index ec93abbbb..890c7df2a 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua @@ -173,11 +173,17 @@ probeInterval.description = translate("The interval between initiating probes. E -- 分流 if #nodes_table > 0 then - o = s:option(ListValue, "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 = s:option(Flag, "preproxy_enabled", translate("Preproxy")) o:depends("protocol", "_shunt") - o:value("nil", translate("Close")) - dialerProxy = s:option(Flag, "dialerProxy", translate("dialerProxy")) - dialerProxy:depends({ type = "Xray", protocol = "_shunt" , }) + o.rmempty = false + o = s:option(ListValue, "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("preproxy_enabled", "1") + local dialerProxy = s:option(Flag, "dialerProxy", translate("dialerProxy")) + dialerProxy.hidden = true + dialerProxy:depends({ type = "Xray", protocol = "_shunt", preproxy_enabled = "1" }) + for k, v in pairs(balancers_table) do + o:value(v.id, v.remarks) + end for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) --dialerProxy:depends({ type = "Xray", main_node = v.id }) @@ -193,17 +199,17 @@ uci:foreach(appname, "shunt_rules", function(e) o:value("_blackhole", translate("Blackhole")) o:depends("protocol", "_shunt") - for k, v in pairs(balancers_table) do - o:value(v.id, v.remarks) - end if #nodes_table > 0 then + for k, v in pairs(balancers_table) do + o:value(v.id, v.remarks) + end local pt = s:option(ListValue, e[".name"] .. "_proxy_tag", string.format('* %s', e.remarks .. " " .. translate("Preproxy"))) pt:value("nil", translate("Close")) pt:value("main", translate("Preproxy Node")) pt.default = "nil" for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) - pt:depends(e[".name"], v.id) + pt:depends({ preproxy_enabled = "1", [e[".name"]] = v.id }) end end end @@ -216,21 +222,22 @@ shunt_tips.cfgvalue = function(t, n) end shunt_tips:depends("protocol", "_shunt") -default_node = s:option(ListValue, "default_node", string.format('* %s', translate("Default"))) +local default_node = s:option(ListValue, "default_node", string.format('* %s', translate("Default"))) +default_node:depends("protocol", "_shunt") default_node:value("_direct", translate("Direct Connection")) default_node:value("_blackhole", translate("Blackhole")) -for k, v in pairs(nodes_table) do default_node:value(v.id, v.remarks) end -default_node:depends("protocol", "_shunt") if #nodes_table > 0 then + for k, v in pairs(balancers_table) do + default_node:value(v.id, v.remarks) + end local dpt = s:option(ListValue, "default_proxy_tag", 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.")) dpt:value("nil", translate("Close")) dpt:value("main", translate("Preproxy Node")) dpt.default = "nil" for k, v in pairs(nodes_table) do - if v.protocol ~= "_balancing" then - dpt:depends("default_node", v.id) - end + default_node:value(v.id, v.remarks) + dpt:depends({ preproxy_enabled = "1", default_node = v.id }) end end