luci-app-passwall: sync upstream
This commit is contained in:
parent
40c1811cd6
commit
b5ab8a0a18
@ -642,24 +642,31 @@ function gen_config(var)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_balancer_tag(_node_id)
|
local function gen_loopback(outbound_tag, loopback_dst)
|
||||||
return "balancer-" .. _node_id
|
if not outbound_tag or outbound_tag == "" then return nil end
|
||||||
end
|
local inbound_tag = loopback_dst and "lo-to-" .. loopback_dst or outbound_tag .. "-lo"
|
||||||
|
|
||||||
local function gen_loopback(outboundTag, dst_node_id)
|
|
||||||
if not outboundTag then return nil end
|
|
||||||
local inboundTag = dst_node_id and "loop-in-" .. dst_node_id or outboundTag .. "-lo"
|
|
||||||
table.insert(outbounds, {
|
table.insert(outbounds, {
|
||||||
protocol = "loopback",
|
protocol = "loopback",
|
||||||
tag = outboundTag,
|
tag = outbound_tag,
|
||||||
settings = { inboundTag = inboundTag }
|
settings = { inboundTag = inbound_tag }
|
||||||
})
|
})
|
||||||
return inboundTag
|
return inbound_tag
|
||||||
end
|
end
|
||||||
|
|
||||||
local function gen_balancer(_node, loopbackTag)
|
local function gen_balancer(_node, loopback_tag)
|
||||||
|
local balancer_id = _node[".name"]
|
||||||
|
local balancer_tag = "balancer-" .. balancer_id
|
||||||
|
local loopback_dst = balancer_id -- route destination for the loopback outbound
|
||||||
|
if not loopback_tag or loopback_tag == "" then loopback_tag = balancer_id end
|
||||||
|
-- existing balancer
|
||||||
|
for _, v in ipairs(balancers) do
|
||||||
|
if v.tag == balancer_tag then
|
||||||
|
gen_loopback(loopback_tag, loopback_dst)
|
||||||
|
return balancer_tag
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- new balancer
|
||||||
local blc_nodes = _node.balancing_node
|
local blc_nodes = _node.balancing_node
|
||||||
local fallback_node_id = _node.fallback_node
|
|
||||||
local length = #blc_nodes
|
local length = #blc_nodes
|
||||||
local valid_nodes = {}
|
local valid_nodes = {}
|
||||||
for i = 1, length do
|
for i = 1, length do
|
||||||
@ -682,10 +689,11 @@ function gen_config(var)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if fallback_node_id == "" then
|
if #valid_nodes == 0 then return nil end
|
||||||
fallback_node_id = nil
|
|
||||||
end
|
-- fallback node
|
||||||
if fallback_node_id then
|
local fallback_node_id = _node.fallback_node
|
||||||
|
if fallback_node_id and fallback_node_id ~= "" then
|
||||||
local is_new_node = true
|
local is_new_node = true
|
||||||
for _, outbound in ipairs(outbounds) do
|
for _, outbound in ipairs(outbounds) do
|
||||||
if outbound.tag == fallback_node_id then
|
if outbound.tag == fallback_node_id then
|
||||||
@ -703,44 +711,36 @@ function gen_config(var)
|
|||||||
fallback_node_id = nil
|
fallback_node_id = nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local valid = gen_balancer(fallback_node)
|
if not gen_balancer(fallback_node) then
|
||||||
if not valid then
|
|
||||||
fallback_node_id = nil
|
fallback_node_id = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
table.insert(balancers, {
|
||||||
local valid = nil
|
tag = balancer_tag,
|
||||||
if #valid_nodes > 0 then
|
selector = valid_nodes,
|
||||||
local balancerTag = get_balancer_tag(_node[".name"])
|
fallbackTag = fallback_node_id,
|
||||||
table.insert(balancers, {
|
strategy = { type = _node.balancingStrategy or "random" }
|
||||||
tag = balancerTag,
|
})
|
||||||
selector = valid_nodes,
|
if _node.balancingStrategy == "leastPing" then
|
||||||
fallbackTag = fallback_node_id,
|
if not observatory then
|
||||||
strategy = { type = _node.balancingStrategy or "random" }
|
observatory = {
|
||||||
})
|
subjectSelector = { "blc-" },
|
||||||
if _node.balancingStrategy == "leastPing" then
|
probeUrl = _node.useCustomProbeUrl and _node.probeUrl or nil,
|
||||||
if not observatory then
|
probeInterval = _node.probeInterval or "1m",
|
||||||
observatory = {
|
enableConcurrency = true
|
||||||
subjectSelector = { "blc-" },
|
}
|
||||||
probeUrl = _node.useCustomProbeUrl and _node.probeUrl or nil,
|
|
||||||
probeInterval = _node.probeInterval or "1m",
|
|
||||||
enableConcurrency = true
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
if loopbackTag == nil or loopbackTag =="" then loopbackTag = _node[".name"] end
|
|
||||||
local inboundTag = gen_loopback(loopbackTag, _node[".name"])
|
|
||||||
table.insert(rules, { type = "field", inboundTag = { inboundTag }, balancerTag = balancerTag })
|
|
||||||
valid = true
|
|
||||||
end
|
end
|
||||||
return valid
|
local inbound_tag = gen_loopback(loopback_tag, loopback_dst)
|
||||||
|
table.insert(rules, { type = "field", inboundTag = { inbound_tag }, balancerTag = balancer_tag })
|
||||||
|
return balancer_tag
|
||||||
end
|
end
|
||||||
|
|
||||||
local function set_outbound_detour(node, outbound, outbounds_table, shunt_rule_name)
|
local function set_outbound_detour(node, outbound, outbounds_table, shunt_rule_name)
|
||||||
if not node or not outbound or not outbounds_table then return nil end
|
if not node or not outbound or not outbounds_table then return nil end
|
||||||
local default_outTag = outbound.tag
|
local default_out_tag = outbound.tag
|
||||||
|
|
||||||
if node.to_node then
|
if node.to_node then
|
||||||
local to_node = uci:get_all(appname, node.to_node)
|
local to_node = uci:get_all(appname, node.to_node)
|
||||||
@ -759,33 +759,35 @@ function gen_config(var)
|
|||||||
transportLayer = true
|
transportLayer = true
|
||||||
}
|
}
|
||||||
table.insert(outbounds_table, to_outbound)
|
table.insert(outbounds_table, to_outbound)
|
||||||
default_outTag = to_outbound.tag
|
default_out_tag = to_outbound.tag
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return default_outTag
|
return default_out_tag
|
||||||
end
|
end
|
||||||
|
|
||||||
if node.protocol == "_shunt" then
|
if node.protocol == "_shunt" then
|
||||||
local proxy_tag = "main"
|
|
||||||
local proxy_node_id = node["main_node"]
|
local proxy_node_id = node["main_node"]
|
||||||
local proxy_node = node.preproxy_enabled == "1" and proxy_node_id and uci:get_all(appname, proxy_node_id) or nil
|
local proxy_tag = "main"
|
||||||
local proxy_outboundTag, proxy_balancerTag
|
local proxy_balancer_tag
|
||||||
|
local proxy_nodes
|
||||||
|
|
||||||
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, nil end
|
if not rule_name then return nil, nil end
|
||||||
if not _node_id then _node_id = node[rule_name] or "nil" end
|
if not _node_id then
|
||||||
local rule_outboundTag
|
_node_id = node[rule_name] or nil
|
||||||
local rule_balancerTag
|
if not _node_id then return nil, nil end
|
||||||
|
end
|
||||||
if _node_id == "_direct" then
|
if _node_id == "_direct" then
|
||||||
rule_outboundTag = "direct"
|
return "direct", nil
|
||||||
elseif _node_id == "_blackhole" then
|
elseif _node_id == "_blackhole" then
|
||||||
rule_outboundTag = "blackhole"
|
return "blackhole", nil
|
||||||
elseif _node_id == "_default" then
|
elseif _node_id == "_default" then
|
||||||
rule_outboundTag = "default"
|
return "default", nil
|
||||||
elseif _node_id:find("Socks_") then
|
elseif _node_id:find("Socks_") then
|
||||||
local socks_id = _node_id:sub(1 + #"Socks_")
|
local socks_id = _node_id:sub(1 + #"Socks_")
|
||||||
local socks_node = uci:get_all(appname, socks_id) or nil
|
local socks_node = uci:get_all(appname, socks_id) or nil
|
||||||
|
local socks_tag
|
||||||
if socks_node then
|
if socks_node then
|
||||||
local _node = {
|
local _node = {
|
||||||
type = "Xray",
|
type = "Xray",
|
||||||
@ -798,124 +800,121 @@ 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
|
||||||
table.insert(outbounds, outbound)
|
table.insert(outbounds, outbound)
|
||||||
rule_outboundTag = rule_name
|
socks_tag = outbound.tag
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif _node_id ~= "nil" then
|
return socks_tag, nil
|
||||||
local _node = uci:get_all(appname, _node_id)
|
end
|
||||||
if not _node then return nil, nil end
|
|
||||||
|
|
||||||
if api.is_normal_node(_node) then
|
local _node = uci:get_all(appname, _node_id)
|
||||||
local use_proxy = proxy_node and node[rule_name .. "_proxy_tag"] == proxy_tag and _node_id ~= proxy_node_id
|
if not _node then return nil, nil end
|
||||||
if use_proxy and proxy_balancerTag then
|
|
||||||
for _, blc_node_id in ipairs(proxy_node.balancing_node) do
|
if api.is_normal_node(_node) then
|
||||||
if _node_id == blc_node_id then
|
local use_proxy = proxy_tag and node[rule_name .. "_proxy_tag"] == proxy_tag and _node_id ~= proxy_node_id
|
||||||
use_proxy = false
|
if use_proxy and proxy_balancer_tag and proxy_nodes[_node_id] then use_proxy = false end
|
||||||
break
|
local copied_outbound
|
||||||
end
|
for index, value in ipairs(outbounds) do
|
||||||
end
|
if value["_flag_tag"] == _node_id and value["_flag_proxy_tag"] == (use_proxy and proxy_tag or "nil") then
|
||||||
|
copied_outbound = api.clone(value)
|
||||||
|
break
|
||||||
end
|
end
|
||||||
local copied_outbound
|
end
|
||||||
for index, value in ipairs(outbounds) do
|
if copied_outbound then
|
||||||
if value["_flag_tag"] == _node_id and value["_flag_proxy_tag"] == proxy_tag then
|
copied_outbound.tag = rule_name
|
||||||
copied_outbound = api.clone(value)
|
table.insert(outbounds, copied_outbound)
|
||||||
break
|
return copied_outbound.tag, nil
|
||||||
end
|
end
|
||||||
|
--new outbound
|
||||||
|
if use_proxy and (_node.type ~= "Xray" or _node.flow == "xtls-rprx-vision") then
|
||||||
|
new_port = get_new_port()
|
||||||
|
table.insert(inbounds, {
|
||||||
|
tag = "proxy_" .. rule_name,
|
||||||
|
listen = "127.0.0.1",
|
||||||
|
port = new_port,
|
||||||
|
protocol = "dokodemo-door",
|
||||||
|
settings = {network = "tcp,udp", address = _node.address, port = tonumber(_node.port)}
|
||||||
|
})
|
||||||
|
if _node.tls_serverName == nil then
|
||||||
|
_node.tls_serverName = _node.address
|
||||||
end
|
end
|
||||||
if copied_outbound then
|
_node.address = "127.0.0.1"
|
||||||
copied_outbound.tag = rule_name
|
_node.port = new_port
|
||||||
table.insert(outbounds, copied_outbound)
|
table.insert(rules, 1, {
|
||||||
rule_outboundTag = rule_name
|
type = "field",
|
||||||
else
|
inboundTag = {"proxy_" .. rule_name},
|
||||||
if use_proxy and (_node.type ~= "Xray" or _node.flow == "xtls-rprx-vision") then
|
outboundTag = not proxy_balancer_tag and proxy_tag or nil,
|
||||||
new_port = get_new_port()
|
balancerTag = proxy_balancer_tag
|
||||||
table.insert(inbounds, {
|
})
|
||||||
tag = "proxy_" .. rule_name,
|
end
|
||||||
listen = "127.0.0.1",
|
local proxy_table = {
|
||||||
port = new_port,
|
proxy = use_proxy and 1 or 0,
|
||||||
protocol = "dokodemo-door",
|
tag = use_proxy and proxy_tag or nil
|
||||||
settings = {network = "tcp,udp", address = _node.address, port = tonumber(_node.port)}
|
}
|
||||||
})
|
if xray_settings.fragment == "1" and not proxy_table.tag then
|
||||||
if _node.tls_serverName == nil then
|
proxy_table.fragment = true
|
||||||
_node.tls_serverName = _node.address
|
end
|
||||||
end
|
local outbound = gen_outbound(flag, _node, rule_name, proxy_table)
|
||||||
_node.address = "127.0.0.1"
|
local outbound_tag
|
||||||
_node.port = new_port
|
if outbound then
|
||||||
table.insert(rules, 1, {
|
set_outbound_detour(_node, outbound, outbounds, rule_name)
|
||||||
type = "field",
|
table.insert(outbounds, outbound)
|
||||||
inboundTag = {"proxy_" .. rule_name},
|
outbound_tag = outbound.tag
|
||||||
outboundTag = proxy_outboundTag,
|
end
|
||||||
balancerTag = proxy_balancerTag
|
return outbound_tag, nil
|
||||||
})
|
elseif _node.protocol == "_balancing" then
|
||||||
end
|
|
||||||
local proxy_table = {
|
return nil, gen_balancer(_node, rule_name)
|
||||||
proxy = use_proxy and 1 or 0,
|
elseif _node.protocol == "_iface" then
|
||||||
tag = use_proxy and proxy_tag or nil
|
if _node.iface then
|
||||||
}
|
local outbound = {
|
||||||
if xray_settings.fragment == "1" and not proxy_table.tag then
|
protocol = "freedom",
|
||||||
proxy_table.fragment = true
|
tag = rule_name,
|
||||||
end
|
streamSettings = {
|
||||||
local outbound = gen_outbound(flag, _node, rule_name, proxy_table)
|
sockopt = {
|
||||||
if outbound then
|
mark = 255,
|
||||||
set_outbound_detour(_node, outbound, outbounds, rule_name)
|
interface = _node.iface
|
||||||
table.insert(outbounds, outbound)
|
|
||||||
rule_outboundTag = rule_name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif _node.protocol == "_balancing" then
|
|
||||||
local is_new_balancer = true
|
|
||||||
rule_balancerTag = get_balancer_tag(_node_id)
|
|
||||||
for _, v in ipairs(balancers) do
|
|
||||||
if v.tag == rule_balancerTag then
|
|
||||||
is_new_balancer = false
|
|
||||||
gen_loopback(rule_name, _node_id)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if is_new_balancer then
|
|
||||||
local valid = gen_balancer(_node, rule_name)
|
|
||||||
if not valid then
|
|
||||||
rule_balancerTag = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
elseif _node.protocol == "_iface" then
|
|
||||||
if _node.iface then
|
|
||||||
local outbound = {
|
|
||||||
protocol = "freedom",
|
|
||||||
tag = rule_name,
|
|
||||||
streamSettings = {
|
|
||||||
sockopt = {
|
|
||||||
mark = 255,
|
|
||||||
interface = _node.iface
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table.insert(outbounds, outbound)
|
}
|
||||||
rule_outboundTag = rule_name
|
table.insert(outbounds, outbound)
|
||||||
sys.call("touch /tmp/etc/passwall/iface/" .. _node.iface)
|
sys.call("touch /tmp/etc/passwall/iface/" .. _node.iface)
|
||||||
end
|
return outbound.tag, nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return rule_outboundTag, rule_balancerTag
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--proxy_node
|
--proxy_node
|
||||||
if proxy_node then
|
if node.preproxy_enabled == "1" and proxy_node_id then
|
||||||
proxy_outboundTag, proxy_balancerTag = gen_shunt_node(proxy_tag, proxy_node_id)
|
local proxy_outbound_tag
|
||||||
if not proxy_outboundTag and not proxy_balancerTag then
|
proxy_outbound_tag, proxy_balancer_tag = gen_shunt_node(proxy_tag, proxy_node_id)
|
||||||
proxy_node = nil
|
if proxy_balancer_tag then
|
||||||
|
local _node_id = proxy_node_id
|
||||||
|
proxy_nodes = {}
|
||||||
|
while _node_id do
|
||||||
|
_node = uci:get_all(appname, _node_id)
|
||||||
|
if not _node then break end
|
||||||
|
if _node.protocol ~= "_balancing" then
|
||||||
|
proxy_nodes[_node_id] = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
local _blc_nodes = _node.balancing_node
|
||||||
|
for i = 1, #_blc_nodes do proxy_nodes[_blc_nodes[i]] = true end
|
||||||
|
_node_id = _node.fallback_node
|
||||||
|
end
|
||||||
|
else
|
||||||
|
proxy_tag = proxy_outbound_tag
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--default_node
|
--default_node
|
||||||
local default_node_id = node.default_node or "_direct"
|
local default_node_id = node.default_node or "_direct"
|
||||||
local default_outboundTag, default_balancerTag = gen_shunt_node("default", default_node_id)
|
local default_outbound_tag, default_balancer_tag = gen_shunt_node("default", default_node_id)
|
||||||
--shunt rule
|
--shunt rule
|
||||||
uci:foreach(appname, "shunt_rules", function(e)
|
uci:foreach(appname, "shunt_rules", function(e)
|
||||||
local outboundTag, balancerTag = gen_shunt_node(e[".name"])
|
local outbound_tag, balancer_tag = gen_shunt_node(e[".name"])
|
||||||
if outboundTag or balancerTag and e.remarks then
|
if outbound_tag or balancer_tag and e.remarks then
|
||||||
if outboundTag == "default" then
|
if outbound_tag == "default" then
|
||||||
outboundTag = default_outboundTag
|
outbound_tag = default_outbound_tag
|
||||||
balancerTag = default_balancerTag
|
balancer_tag = default_balancer_tag
|
||||||
end
|
end
|
||||||
local protocols = nil
|
local protocols = nil
|
||||||
if e["protocol"] and e["protocol"] ~= "" then
|
if e["protocol"] and e["protocol"] ~= "" then
|
||||||
@ -924,20 +923,20 @@ function gen_config(var)
|
|||||||
table.insert(protocols, w)
|
table.insert(protocols, w)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
local inboundTag = nil
|
local inbound_tag = nil
|
||||||
if e["inbound"] and e["inbound"] ~= "" then
|
if e["inbound"] and e["inbound"] ~= "" then
|
||||||
inboundTag = {}
|
inbound_tag = {}
|
||||||
if e["inbound"]:find("tproxy") then
|
if e["inbound"]:find("tproxy") then
|
||||||
if tcp_redir_port then
|
if tcp_redir_port then
|
||||||
table.insert(inboundTag, "tcp_redir")
|
table.insert(inbound_tag, "tcp_redir")
|
||||||
end
|
end
|
||||||
if udp_redir_port then
|
if udp_redir_port then
|
||||||
table.insert(inboundTag, "udp_redir")
|
table.insert(inbound_tag, "udp_redir")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if e["inbound"]:find("socks") then
|
if e["inbound"]:find("socks") then
|
||||||
if local_socks_port then
|
if local_socks_port then
|
||||||
table.insert(inboundTag, "socks-in")
|
table.insert(inbound_tag, "socks-in")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -965,9 +964,9 @@ function gen_config(var)
|
|||||||
local rule = {
|
local rule = {
|
||||||
_flag = e.remarks,
|
_flag = e.remarks,
|
||||||
type = "field",
|
type = "field",
|
||||||
inboundTag = inboundTag,
|
inboundTag = inbound_tag,
|
||||||
outboundTag = outboundTag,
|
outboundTag = outbound_tag,
|
||||||
balancerTag = balancerTag,
|
balancerTag = balancer_tag,
|
||||||
network = e["network"] or "tcp,udp",
|
network = e["network"] or "tcp,udp",
|
||||||
source = source,
|
source = source,
|
||||||
sourcePort = nil,
|
sourcePort = nil,
|
||||||
@ -992,11 +991,11 @@ function gen_config(var)
|
|||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if default_outboundTag or default_balancerTag then
|
if default_outbound_tag or default_balancer_tag then
|
||||||
table.insert(rules, {
|
table.insert(rules, {
|
||||||
type = "field",
|
type = "field",
|
||||||
outboundTag = default_outboundTag,
|
outboundTag = default_outbound_tag,
|
||||||
balancerTag = default_balancerTag,
|
balancerTag = default_balancer_tag,
|
||||||
network = "tcp,udp"
|
network = "tcp,udp"
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -1009,9 +1008,9 @@ function gen_config(var)
|
|||||||
}
|
}
|
||||||
elseif node.protocol == "_balancing" then
|
elseif node.protocol == "_balancing" then
|
||||||
if node.balancing_node then
|
if node.balancing_node then
|
||||||
local valid = gen_balancer(node)
|
local balancer_tag = gen_balancer(node)
|
||||||
if valid then
|
if balancer_tag then
|
||||||
table.insert(rules, { type = "field", network = "tcp,udp", balancerTag = get_balancer_tag(node_id) })
|
table.insert(rules, { type = "field", network = "tcp,udp", balancerTag = balancer_tag })
|
||||||
end
|
end
|
||||||
routing = {
|
routing = {
|
||||||
balancers = balancers,
|
balancers = balancers,
|
||||||
@ -1114,11 +1113,11 @@ function gen_config(var)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
]]--
|
]]--
|
||||||
local dns_outboundTag = "direct"
|
local dns_outbound_tag = "direct"
|
||||||
if dns_socks_address and dns_socks_port then
|
if dns_socks_address and dns_socks_port then
|
||||||
dns_outboundTag = "out"
|
dns_outbound_tag = "out"
|
||||||
table.insert(outbounds, 1, {
|
table.insert(outbounds, 1, {
|
||||||
tag = dns_outboundTag,
|
tag = dns_outbound_tag,
|
||||||
protocol = "socks",
|
protocol = "socks",
|
||||||
streamSettings = {
|
streamSettings = {
|
||||||
network = "tcp",
|
network = "tcp",
|
||||||
@ -1138,10 +1137,10 @@ function gen_config(var)
|
|||||||
})
|
})
|
||||||
else
|
else
|
||||||
if node_id and tcp_redir_port then
|
if node_id and tcp_redir_port then
|
||||||
dns_outboundTag = node_id
|
dns_outbound_tag = node_id
|
||||||
local node = uci:get_all(appname, node_id)
|
local node = uci:get_all(appname, node_id)
|
||||||
if node.protocol == "_shunt" then
|
if node.protocol == "_shunt" then
|
||||||
dns_outboundTag = "default"
|
dns_outbound_tag = "default"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1163,7 +1162,7 @@ function gen_config(var)
|
|||||||
tag = "dns-out",
|
tag = "dns-out",
|
||||||
protocol = "dns",
|
protocol = "dns",
|
||||||
proxySettings = {
|
proxySettings = {
|
||||||
tag = dns_outboundTag
|
tag = dns_outbound_tag
|
||||||
},
|
},
|
||||||
settings = {
|
settings = {
|
||||||
address = remote_dns_tcp_server,
|
address = remote_dns_tcp_server,
|
||||||
@ -1190,7 +1189,7 @@ function gen_config(var)
|
|||||||
remote_dns_tcp_server
|
remote_dns_tcp_server
|
||||||
},
|
},
|
||||||
port = tonumber(remote_dns_tcp_port),
|
port = tonumber(remote_dns_tcp_port),
|
||||||
outboundTag = dns_outboundTag
|
outboundTag = dns_outbound_tag
|
||||||
})
|
})
|
||||||
if _remote_dns_host then
|
if _remote_dns_host then
|
||||||
table.insert(rules, {
|
table.insert(rules, {
|
||||||
@ -1202,7 +1201,7 @@ function gen_config(var)
|
|||||||
_remote_dns_host
|
_remote_dns_host
|
||||||
},
|
},
|
||||||
port = tonumber(remote_dns_doh_port),
|
port = tonumber(remote_dns_doh_port),
|
||||||
outboundTag = dns_outboundTag
|
outboundTag = dns_outbound_tag
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
if remote_dns_doh_ip then
|
if remote_dns_doh_ip then
|
||||||
@ -1215,7 +1214,7 @@ function gen_config(var)
|
|||||||
remote_dns_doh_ip
|
remote_dns_doh_ip
|
||||||
},
|
},
|
||||||
port = tonumber(remote_dns_doh_port),
|
port = tonumber(remote_dns_doh_port),
|
||||||
outboundTag = dns_outboundTag
|
outboundTag = dns_outbound_tag
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -327,7 +327,7 @@ run_ipt2socks() {
|
|||||||
run_singbox() {
|
run_singbox() {
|
||||||
local flag type node tcp_redir_port udp_redir_port socks_address socks_port socks_username socks_password http_address http_port http_username http_password
|
local flag type node tcp_redir_port udp_redir_port socks_address socks_port socks_username socks_password http_address http_port http_username http_password
|
||||||
local dns_listen_port direct_dns_port direct_dns_udp_server remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_fakedns remote_dns_query_strategy dns_cache dns_socks_address dns_socks_port
|
local dns_listen_port direct_dns_port direct_dns_udp_server remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_fakedns remote_dns_query_strategy dns_cache dns_socks_address dns_socks_port
|
||||||
local loglevel log_file config_file
|
local loglevel log_file config_file server_host server_port
|
||||||
local _extra_param=""
|
local _extra_param=""
|
||||||
eval_set_val $@
|
eval_set_val $@
|
||||||
[ -z "$type" ] && {
|
[ -z "$type" ] && {
|
||||||
@ -353,6 +353,8 @@ run_singbox() {
|
|||||||
|
|
||||||
[ -n "$flag" ] && _extra_param="${_extra_param} -flag $flag"
|
[ -n "$flag" ] && _extra_param="${_extra_param} -flag $flag"
|
||||||
[ -n "$node" ] && _extra_param="${_extra_param} -node $node"
|
[ -n "$node" ] && _extra_param="${_extra_param} -node $node"
|
||||||
|
[ -n "$server_host" ] && _extra_param="${_extra_param} -server_host $server_host"
|
||||||
|
[ -n "$server_port" ] && _extra_param="${_extra_param} -server_port $server_port"
|
||||||
[ -n "$tcp_redir_port" ] && _extra_param="${_extra_param} -tcp_redir_port $tcp_redir_port"
|
[ -n "$tcp_redir_port" ] && _extra_param="${_extra_param} -tcp_redir_port $tcp_redir_port"
|
||||||
[ -n "$udp_redir_port" ] && _extra_param="${_extra_param} -udp_redir_port $udp_redir_port"
|
[ -n "$udp_redir_port" ] && _extra_param="${_extra_param} -udp_redir_port $udp_redir_port"
|
||||||
[ -n "$socks_address" ] && _extra_param="${_extra_param} -local_socks_address $socks_address"
|
[ -n "$socks_address" ] && _extra_param="${_extra_param} -local_socks_address $socks_address"
|
||||||
@ -404,7 +406,7 @@ run_singbox() {
|
|||||||
run_xray() {
|
run_xray() {
|
||||||
local flag type node tcp_redir_port udp_redir_port socks_address socks_port socks_username socks_password http_address http_port http_username http_password
|
local flag type node tcp_redir_port udp_redir_port socks_address socks_port socks_username socks_password http_address http_port http_username http_password
|
||||||
local dns_listen_port remote_dns_udp_server remote_dns_tcp_server remote_dns_doh dns_client_ip dns_query_strategy dns_cache dns_socks_address dns_socks_port
|
local dns_listen_port remote_dns_udp_server remote_dns_tcp_server remote_dns_doh dns_client_ip dns_query_strategy dns_cache dns_socks_address dns_socks_port
|
||||||
local loglevel log_file config_file
|
local loglevel log_file config_file server_host server_port
|
||||||
local _extra_param=""
|
local _extra_param=""
|
||||||
eval_set_val $@
|
eval_set_val $@
|
||||||
[ -z "$type" ] && {
|
[ -z "$type" ] && {
|
||||||
@ -419,6 +421,8 @@ run_xray() {
|
|||||||
[ -z "$loglevel" ] && local loglevel=$(config_t_get global loglevel "warning")
|
[ -z "$loglevel" ] && local loglevel=$(config_t_get global loglevel "warning")
|
||||||
[ -n "$flag" ] && _extra_param="${_extra_param} -flag $flag"
|
[ -n "$flag" ] && _extra_param="${_extra_param} -flag $flag"
|
||||||
[ -n "$node" ] && _extra_param="${_extra_param} -node $node"
|
[ -n "$node" ] && _extra_param="${_extra_param} -node $node"
|
||||||
|
[ -n "$server_host" ] && _extra_param="${_extra_param} -server_host $server_host"
|
||||||
|
[ -n "$server_port" ] && _extra_param="${_extra_param} -server_port $server_port"
|
||||||
[ -n "$tcp_redir_port" ] && _extra_param="${_extra_param} -tcp_redir_port $tcp_redir_port"
|
[ -n "$tcp_redir_port" ] && _extra_param="${_extra_param} -tcp_redir_port $tcp_redir_port"
|
||||||
[ -n "$udp_redir_port" ] && _extra_param="${_extra_param} -udp_redir_port $udp_redir_port"
|
[ -n "$udp_redir_port" ] && _extra_param="${_extra_param} -udp_redir_port $udp_redir_port"
|
||||||
[ -n "$socks_address" ] && _extra_param="${_extra_param} -local_socks_address $socks_address"
|
[ -n "$socks_address" ] && _extra_param="${_extra_param} -local_socks_address $socks_address"
|
||||||
@ -595,7 +599,7 @@ run_socks() {
|
|||||||
config_file=$(echo $config_file | sed "s/SOCKS/HTTP_SOCKS/g")
|
config_file=$(echo $config_file | sed "s/SOCKS/HTTP_SOCKS/g")
|
||||||
local _args="http_port=$http_port"
|
local _args="http_port=$http_port"
|
||||||
}
|
}
|
||||||
[ -n "$relay_port" ] && _args="${_args} -server_host $server_host -server_port $port"
|
[ -n "$relay_port" ] && _args="${_args} server_host=$server_host server_port=$port"
|
||||||
run_singbox flag=$flag node=$node socks_port=$socks_port config_file=$config_file log_file=$log_file ${_args}
|
run_singbox flag=$flag node=$node socks_port=$socks_port config_file=$config_file log_file=$log_file ${_args}
|
||||||
;;
|
;;
|
||||||
xray)
|
xray)
|
||||||
@ -604,7 +608,7 @@ run_socks() {
|
|||||||
config_file=$(echo $config_file | sed "s/SOCKS/HTTP_SOCKS/g")
|
config_file=$(echo $config_file | sed "s/SOCKS/HTTP_SOCKS/g")
|
||||||
local _args="http_port=$http_port"
|
local _args="http_port=$http_port"
|
||||||
}
|
}
|
||||||
[ -n "$relay_port" ] && _args="${_args} -server_host $server_host -server_port $port"
|
[ -n "$relay_port" ] && _args="${_args} server_host=$server_host server_port=$port"
|
||||||
run_xray flag=$flag node=$node socks_port=$socks_port config_file=$config_file log_file=$log_file ${_args}
|
run_xray flag=$flag node=$node socks_port=$socks_port config_file=$config_file log_file=$log_file ${_args}
|
||||||
;;
|
;;
|
||||||
trojan*)
|
trojan*)
|
||||||
|
Loading…
Reference in New Issue
Block a user