luci-app-passwall: fix shunt bug caused by order

Signed-off-by: CN_SZTL <cnsztl@project-openwrt.eu.org>
This commit is contained in:
monokoo 2021-02-13 17:57:11 +08:00 committed by CN_SZTL
parent df3d3d9fa0
commit 0ec77d950f
No known key found for this signature in database
GPG Key ID: 6850B6345C862176

View File

@ -260,57 +260,6 @@ if node_section then
if node.protocol == "_shunt" then
local rules = {}
local default_node_id = node.default_node or "_direct"
local outboundTag
if default_node_id == "_direct" then
outboundTag = "direct"
elseif default_node_id == "_blackhole" then
outboundTag = "blackhole"
else
local default_node = ucursor:get_all(appname, default_node_id)
local main_node_id = node.main_node or "nil"
if main_node_id ~= "nil" then
if main_node_id == default_node_id then
else
new_port = get_new_port()
table.insert(inbounds, {
tag = "proxy_default",
listen = "127.0.0.1",
port = new_port,
protocol = "dokodemo-door",
settings = {network = "tcp,udp", address = default_node.address, port = tonumber(default_node.port)}
})
if default_node.tls_serverName == nil then
default_node.tls_serverName = default_node.address
end
default_node.address = "127.0.0.1"
default_node.port = new_port
local node = ucursor:get_all(appname, main_node_id)
local outbound = gen_outbound(node, "main")
if outbound then
table.insert(outbounds, outbound)
table.insert(rules, 1, {
type = "field",
inboundTag = {"proxy_default"},
outboundTag = "main"
})
end
end
end
local default_outbound = gen_outbound(default_node, "default")
if default_outbound then
table.insert(outbounds, default_outbound)
outboundTag = "default"
end
end
if outboundTag then
table.insert(rules, {
type = "field",
outboundTag = outboundTag,
network = network
})
end
ucursor:foreach(appname, "shunt_rules", function(e)
local name = e[".name"]
local _node_id = node[name] or "nil"
@ -375,6 +324,58 @@ if node_section then
end
end
end)
local default_node_id = node.default_node or "_direct"
local outboundTag
if default_node_id == "_direct" then
outboundTag = "direct"
elseif default_node_id == "_blackhole" then
outboundTag = "blackhole"
else
local default_node = ucursor:get_all(appname, default_node_id)
local main_node_id = node.main_node or "nil"
if main_node_id ~= "nil" then
if main_node_id == default_node_id then
else
new_port = get_new_port()
table.insert(inbounds, {
tag = "proxy_default",
listen = "127.0.0.1",
port = new_port,
protocol = "dokodemo-door",
settings = {network = "tcp,udp", address = default_node.address, port = tonumber(default_node.port)}
})
if default_node.tls_serverName == nil then
default_node.tls_serverName = default_node.address
end
default_node.address = "127.0.0.1"
default_node.port = new_port
local node = ucursor:get_all(appname, main_node_id)
local outbound = gen_outbound(node, "main")
if outbound then
table.insert(outbounds, outbound)
table.insert(rules, 1, {
type = "field",
inboundTag = {"proxy_default"},
outboundTag = "main"
})
end
end
end
local default_outbound = gen_outbound(default_node, "default")
if default_outbound then
table.insert(outbounds, default_outbound)
outboundTag = "default"
end
end
if outboundTag then
table.insert(rules, {
type = "field",
outboundTag = outboundTag,
network = network
})
end
routing = {
domainStrategy = node.domainStrategy or "AsIs",
rules = rules