From 5cd087f026b5c2015eb5bf77f4f826f42ad64122 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Mon, 18 Nov 2024 16:28:17 +0800 Subject: [PATCH] update 2024-11-18 16:28:17 --- luci-app-passwall/Makefile | 2 +- .../luasrc/passwall/util_sing-box.lua | 21 +++++++------------ .../luasrc/passwall/util_xray.lua | 20 +++++++++++------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/luci-app-passwall/Makefile b/luci-app-passwall/Makefile index ce7412269..4a14c500f 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:=24.11.18 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_CONFIG_DEPENDS:= \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ diff --git a/luci-app-passwall/luasrc/passwall/util_sing-box.lua b/luci-app-passwall/luasrc/passwall/util_sing-box.lua index 6a74cd40a..d4f516878 100644 --- a/luci-app-passwall/luasrc/passwall/util_sing-box.lua +++ b/luci-app-passwall/luasrc/passwall/util_sing-box.lua @@ -927,11 +927,9 @@ function gen_config(var) if node.protocol == "_shunt" then local rules = {} - local preproxy_enabled = node.preproxy_enabled == "1" - local preproxy_rule_name = "main" - local preproxy_tag = "main" - local preproxy_node_id = node["main_node"] - local preproxy_node = preproxy_enabled and preproxy_node_id and uci:get_all(appname, preproxy_node_id) or nil + local preproxy_rule_name = node.preproxy_enabled == "1" and "main" or nil + local preproxy_tag = preproxy_rule_name + local preproxy_node_id = preproxy_rule_name and node["main_node"] or nil local function gen_shunt_node(rule_name, _node_id) if not rule_name then return nil, nil end @@ -956,7 +954,6 @@ function gen_config(var) } local _outbound = gen_outbound(flag, _node, rule_name) if _outbound then - _outbound.tag = _outbound.tag .. ":" .. _node.remarks table.insert(outbounds, _outbound) rule_outboundTag = _outbound.tag end @@ -966,10 +963,10 @@ function gen_config(var) if not _node then return nil, nil end if api.is_normal_node(_node) then - local proxy = preproxy_enabled and node[rule_name .. "_proxy_tag"] == preproxy_rule_name and _node_id ~= preproxy_node_id + local use_proxy = preproxy_tag and node[rule_name .. "_proxy_tag"] == preproxy_rule_name and _node_id ~= preproxy_node_id local copied_outbound for index, value in ipairs(outbounds) do - if value["_id"] == _node_id and value["_flag_proxy_tag"] == preproxy_tag then + if value["_id"] == _node_id and value["_flag_proxy_tag"] == (use_proxy and preproxy_tag or nil) then copied_outbound = api.clone(value) break end @@ -979,7 +976,7 @@ function gen_config(var) table.insert(outbounds, copied_outbound) rule_outboundTag = copied_outbound.tag else - if proxy then + if use_proxy then local pre_proxy = nil if _node.type ~= "sing-box" then pre_proxy = true @@ -1006,7 +1003,7 @@ function gen_config(var) end end - local _outbound = gen_outbound(flag, _node, rule_name, { tag = proxy and preproxy_tag or nil }) + local _outbound = gen_outbound(flag, _node, rule_name, { tag = use_proxy and preproxy_tag or nil }) if _outbound then _outbound.tag = _outbound.tag .. ":" .. _node.remarks rule_outboundTag = set_outbound_detour(_node, _outbound, outbounds, rule_name) @@ -1030,12 +1027,10 @@ function gen_config(var) return rule_outboundTag end - if preproxy_node then + if preproxy_tag and preproxy_node_id then local preproxy_outboundTag = gen_shunt_node(preproxy_rule_name, preproxy_node_id) if preproxy_outboundTag then preproxy_tag = preproxy_outboundTag - else - preproxy_node = nil end end --default_node diff --git a/luci-app-passwall/luasrc/passwall/util_xray.lua b/luci-app-passwall/luasrc/passwall/util_xray.lua index 04d46f056..30d56e141 100644 --- a/luci-app-passwall/luasrc/passwall/util_xray.lua +++ b/luci-app-passwall/luasrc/passwall/util_xray.lua @@ -758,16 +758,15 @@ function gen_config(var) end -- new balancer local blc_nodes = _node.balancing_node - local length = #blc_nodes local valid_nodes = {} - for i = 1, length do + for i = 1, #blc_nodes do local blc_node_id = blc_nodes[i] local blc_node_tag = "blc-" .. blc_node_id local is_new_blc_node = true for _, outbound in ipairs(outbounds) do - if outbound.tag == blc_node_tag then + if outbound.tag:find("^" .. blc_node_tag) == 1 then is_new_blc_node = false - valid_nodes[#valid_nodes + 1] = blc_node_tag + valid_nodes[#valid_nodes + 1] = outbound.tag break end end @@ -777,7 +776,7 @@ function gen_config(var) if outbound then outbound.tag = outbound.tag .. ":" .. blc_node.remarks table.insert(outbounds, outbound) - valid_nodes[#valid_nodes + 1] = blc_node_tag + valid_nodes[#valid_nodes + 1] = outbound.tag end end end @@ -1241,7 +1240,9 @@ function gen_config(var) } }) else - if COMMON.default_outbound_tag then + if COMMON.default_balancer_tag then + dns_outbound_tag = nil + elseif COMMON.default_outbound_tag then dns_outbound_tag = COMMON.default_outbound_tag end end @@ -1262,9 +1263,9 @@ function gen_config(var) table.insert(outbounds, { tag = "dns-out", protocol = "dns", - proxySettings = { + proxySettings = dns_outbound_tag and { tag = dns_outbound_tag - }, + } or nil, settings = { address = remote_dns_tcp_server, port = tonumber(remote_dns_tcp_port), @@ -1288,6 +1289,7 @@ function gen_config(var) remote_dns_tcp_server }, port = tonumber(remote_dns_tcp_port), + balancerTag = COMMON.default_balancer_tag, outboundTag = dns_outbound_tag }) if _remote_dns_host then @@ -1299,6 +1301,7 @@ function gen_config(var) _remote_dns_host }, port = tonumber(remote_dns_doh_port), + balancerTag = COMMON.default_balancer_tag, outboundTag = dns_outbound_tag }) end @@ -1311,6 +1314,7 @@ function gen_config(var) remote_dns_doh_ip }, port = tonumber(remote_dns_doh_port), + balancerTag = COMMON.default_balancer_tag, outboundTag = dns_outbound_tag }) end