luci-app-passwall2: sync upstream

This commit is contained in:
sbwml 2023-09-17 05:49:47 +08:00
parent 9f37f1615f
commit bc941cf082

View File

@ -694,6 +694,7 @@ function gen_config(var)
local dns_direct_domains = {} local dns_direct_domains = {}
local dns_remote_domains = {} local dns_remote_domains = {}
local dns_block_domains = {}
local dns = nil local dns = nil
local inbounds = {} local inbounds = {}
local outbounds = {} local outbounds = {}
@ -1016,6 +1017,8 @@ function gen_config(var)
if outboundTag == "direct" then if outboundTag == "direct" then
table.insert(dns_direct_domains, w) table.insert(dns_direct_domains, w)
elseif outboundTag == "block" then
table.insert(dns_block_domains, w)
else else
if outboundTag ~= "nil" then if outboundTag ~= "nil" then
table.insert(dns_remote_domains, w) table.insert(dns_remote_domains, w)
@ -1251,9 +1254,41 @@ function gen_config(var)
table.insert(dns.servers, { table.insert(dns.servers, {
tag = "block", tag = "block",
address = "rcode://refused", address = "rcode://success",
}) })
local block_domain = {}
local block_domain_suffix = {}
local block_domain_keyword = {}
local block_domain_regex = {}
local block_geosite = {}
for index, value in ipairs(dns_block_domains) do
if value:find("geosite:") == 1 then
table.insert(block_geosite, value:sub(1 + #"geosite:"))
elseif value:find("regexp:") == 1 then
table.insert(block_domain_regex, value:sub(1 + #"regexp:"))
elseif value:find("full:") == 1 then
table.insert(block_domain, value:sub(1 + #"full:"))
elseif value:find("domain:") == 1 then
table.insert(block_domain_keyword, value:sub(1 + #"domain:"))
else
table.insert(block_domain, value)
end
end
local block_rule = {
server = "block",
domain = #block_domain > 0 and block_domain or nil,
domain_suffix = #block_domain_suffix > 0 and block_domain_suffix or nil,
domain_keyword = #block_domain_keyword > 0 and block_domain_keyword or nil,
domain_regex = #block_domain_regex > 0 and block_domain_regex or nil,
geosite = #block_geosite > 0 and block_geosite or nil,
disable_cache = true,
}
if block_rule.domain or block_rule.domain_suffix or block_rule.domain_keyword or block_rule.domain_regex or block_rule.geosite then
table.insert(dns.rules, block_rule)
end
local default_dns_flag = "remote" local default_dns_flag = "remote"
if node_id and redir_port then if node_id and redir_port then
local node = uci:get_all(appname, node_id) local node = uci:get_all(appname, node_id)