luci-app-passwall2: sync upstream

last commit: 4d67cf8dbd
This commit is contained in:
gitea-action 2024-11-18 17:30:31 +08:00
parent 907a34c5a5
commit 133a45e48e
3 changed files with 25 additions and 31 deletions

View File

@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall2 PKG_NAME:=luci-app-passwall2
PKG_VERSION:=24.11.17 PKG_VERSION:=24.11.18
PKG_RELEASE:=2 PKG_RELEASE:=1
PKG_CONFIG_DEPENDS:= \ PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \

View File

@ -918,14 +918,9 @@ function gen_config(var)
if node.protocol == "_shunt" then if node.protocol == "_shunt" then
local rules = {} local rules = {}
local preproxy_enabled = node.preproxy_enabled == "1" local preproxy_rule_name = node.preproxy_enabled == "1" and "main" or nil
local preproxy_rule_name = "main" local preproxy_tag = preproxy_rule_name
local preproxy_tag = "main" local preproxy_node_id = preproxy_rule_name and node["main_node"] or nil
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
if preproxy_node then
preproxy_tag = preproxy_tag .. ":" .. preproxy_node.remarks
end
local function gen_shunt_node(rule_name, _node_id) local function gen_shunt_node(rule_name, _node_id)
if not rule_name then return nil end if not rule_name then return nil end
@ -950,7 +945,6 @@ function gen_config(var)
} }
local _outbound = gen_outbound(flag, _node, rule_name) local _outbound = gen_outbound(flag, _node, rule_name)
if _outbound then if _outbound then
_outbound.tag = _outbound.tag .. ":" .. _node.remarks
table.insert(outbounds, _outbound) table.insert(outbounds, _outbound)
rule_outboundTag = _outbound.tag rule_outboundTag = _outbound.tag
end end
@ -960,10 +954,10 @@ function gen_config(var)
if not _node then return nil end if not _node then return nil end
if api.is_normal_node(_node) then 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 local copied_outbound
for index, value in ipairs(outbounds) do 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) copied_outbound = api.clone(value)
break break
end end
@ -973,7 +967,7 @@ function gen_config(var)
table.insert(outbounds, copied_outbound) table.insert(outbounds, copied_outbound)
rule_outboundTag = copied_outbound.tag rule_outboundTag = copied_outbound.tag
else else
if proxy then if use_proxy then
local pre_proxy = nil local pre_proxy = nil
if _node.type ~= "sing-box" then if _node.type ~= "sing-box" then
pre_proxy = true pre_proxy = true
@ -999,7 +993,8 @@ function gen_config(var)
}) })
end end
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 if _outbound then
_outbound.tag = _outbound.tag .. ":" .. _node.remarks _outbound.tag = _outbound.tag .. ":" .. _node.remarks
rule_outboundTag = set_outbound_detour(_node, _outbound, outbounds, rule_name) rule_outboundTag = set_outbound_detour(_node, _outbound, outbounds, rule_name)
@ -1023,10 +1018,10 @@ function gen_config(var)
return rule_outboundTag return rule_outboundTag
end end
if preproxy_node then if preproxy_tag and preproxy_node_id then
proxy_outboundTag = gen_shunt_node(preproxy_rule_name, preproxy_node_id) local preproxy_outboundTag = gen_shunt_node(preproxy_rule_name, preproxy_node_id)
if not proxy_outboundTag then if preproxy_outboundTag then
preproxy_node = nil preproxy_tag = preproxy_outboundTag
end end
end end
--default_node --default_node

View File

@ -756,16 +756,15 @@ function gen_config(var)
end end
-- new balancer -- new balancer
local blc_nodes = _node.balancing_node local blc_nodes = _node.balancing_node
local length = #blc_nodes
local valid_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_id = blc_nodes[i]
local blc_node_tag = "blc-" .. blc_node_id local blc_node_tag = "blc-" .. blc_node_id
local is_new_blc_node = true local is_new_blc_node = true
for _, outbound in ipairs(outbounds) do 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 is_new_blc_node = false
valid_nodes[#valid_nodes + 1] = blc_node_tag valid_nodes[#valid_nodes + 1] = outbound.tag
break break
end end
end end
@ -775,7 +774,7 @@ function gen_config(var)
if outbound then if outbound then
outbound.tag = outbound.tag .. ":" .. blc_node.remarks outbound.tag = outbound.tag .. ":" .. blc_node.remarks
table.insert(outbounds, outbound) table.insert(outbounds, outbound)
valid_nodes[#valid_nodes + 1] = blc_node_tag valid_nodes[#valid_nodes + 1] = outbound.tag
end end
end end
end end
@ -1050,6 +1049,7 @@ function gen_config(var)
local domain_table = { local domain_table = {
shunt_rule_name = e[".name"], shunt_rule_name = e[".name"],
outboundTag = outboundTag, outboundTag = outboundTag,
balancerTag = balancerTag,
domain = {}, domain = {},
} }
domains = {} domains = {}
@ -1058,7 +1058,7 @@ function gen_config(var)
table.insert(domains, w) table.insert(domains, w)
table.insert(domain_table.domain, w) table.insert(domain_table.domain, w)
end) end)
if outboundTag and outboundTag ~= "nil" then if (outboundTag and outboundTag ~= "nil") or (balancerTag and balancerTag ~= "nil") then
table.insert(dns_domain_rules, api.clone(domain_table)) table.insert(dns_domain_rules, api.clone(domain_table))
end end
if #domains == 0 then domains = nil end if #domains == 0 then domains = nil end
@ -1107,16 +1107,15 @@ function gen_config(var)
end end
end end
end) end)
--[[
if default_outboundTag or default_balancerTag then if default_balancerTag then
table.insert(rules, { table.insert(rules, {
_flag = "default", ruleTag = "default",
outboundTag = default_outboundTag,
balancerTag = default_balancerTag, balancerTag = default_balancerTag,
network = "tcp,udp" network = "tcp,udp"
}) })
end end
]]
routing = { routing = {
domainStrategy = node.domainStrategy or "AsIs", domainStrategy = node.domainStrategy or "AsIs",
domainMatcher = node.domainMatcher or "hybrid", domainMatcher = node.domainMatcher or "hybrid",
@ -1395,7 +1394,7 @@ function gen_config(var)
--按分流顺序DNS --按分流顺序DNS
if dns_domain_rules and #dns_domain_rules > 0 then if dns_domain_rules and #dns_domain_rules > 0 then
for index, value in ipairs(dns_domain_rules) do for index, value in ipairs(dns_domain_rules) do
if value.outboundTag and value.domain then if value.domain and (value.outboundTag or value.balancerTag) then
local dns_server = nil local dns_server = nil
if value.outboundTag == "direct" then if value.outboundTag == "direct" then
dns_server = api.clone(_direct_dns) dns_server = api.clone(_direct_dns)