luci: optimise
This commit is contained in:
parent
f6fcb28594
commit
bf1213db32
@ -15,24 +15,49 @@ for k, e in ipairs(api.get_valid_nodes()) do
|
|||||||
nodes_table[#nodes_table + 1] = e
|
nodes_table[#nodes_table + 1] = e
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local normal_list = {}
|
||||||
|
local balancing_list = {}
|
||||||
|
local shunt_list = {}
|
||||||
|
local iface_list = {}
|
||||||
|
for k, v in pairs(nodes_table) do
|
||||||
|
if v.node_type == "normal" then
|
||||||
|
normal_list[#normal_list + 1] = v
|
||||||
|
end
|
||||||
|
if v.protocol and v.protocol == "_balancing" then
|
||||||
|
balancing_list[#balancing_list + 1] = v
|
||||||
|
end
|
||||||
|
if v.protocol and v.protocol == "_shunt" then
|
||||||
|
shunt_list[#shunt_list + 1] = v
|
||||||
|
end
|
||||||
|
if v.protocol and v.protocol == "_iface" then
|
||||||
|
iface_list[#iface_list + 1] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local socks_list = {}
|
||||||
|
|
||||||
local tcp_socks_server = "127.0.0.1" .. ":" .. (uci:get(appname, "@global[0]", "tcp_node_socks_port") or "1070")
|
local tcp_socks_server = "127.0.0.1" .. ":" .. (uci:get(appname, "@global[0]", "tcp_node_socks_port") or "1070")
|
||||||
local socks_table = {}
|
local socks_table = {}
|
||||||
socks_table[#socks_table + 1] = {
|
socks_table[#socks_table + 1] = {
|
||||||
id = tcp_socks_server,
|
id = tcp_socks_server,
|
||||||
remarks = tcp_socks_server .. " - " .. translate("TCP Node")
|
remark = tcp_socks_server .. " - " .. translate("TCP Node")
|
||||||
}
|
}
|
||||||
uci:foreach(appname, "socks", function(s)
|
uci:foreach(appname, "socks", function(s)
|
||||||
if s.enabled == "1" and s.node then
|
if s.enabled == "1" and s.node then
|
||||||
local id, remarks
|
local id, remark
|
||||||
for k, n in pairs(nodes_table) do
|
for k, n in pairs(nodes_table) do
|
||||||
if (s.node == n.id) then
|
if (s.node == n.id) then
|
||||||
remarks = n["remark"]; break
|
remark = n["remark"]; break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
id = "127.0.0.1" .. ":" .. s.port
|
id = "127.0.0.1" .. ":" .. s.port
|
||||||
socks_table[#socks_table + 1] = {
|
socks_table[#socks_table + 1] = {
|
||||||
id = id,
|
id = id,
|
||||||
remarks = id .. " - " .. (remarks or translate("Misconfigured"))
|
remark = id .. " - " .. (remark or translate("Misconfigured"))
|
||||||
|
}
|
||||||
|
socks_list[#socks_list + 1] = {
|
||||||
|
id = "Socks_" .. s[".name"],
|
||||||
|
remark = translate("Socks Config") .. " " .. string.format("[%s %s]", s.port, translate("Port"))
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
@ -83,25 +108,6 @@ udp_node:value("tcp", translate("Same as the tcp node"))
|
|||||||
|
|
||||||
-- 分流
|
-- 分流
|
||||||
if (has_singbox or has_xray) and #nodes_table > 0 then
|
if (has_singbox or has_xray) and #nodes_table > 0 then
|
||||||
local normal_list = {}
|
|
||||||
local balancing_list = {}
|
|
||||||
local shunt_list = {}
|
|
||||||
local iface_list = {}
|
|
||||||
for k, v in pairs(nodes_table) do
|
|
||||||
if v.node_type == "normal" then
|
|
||||||
normal_list[#normal_list + 1] = v
|
|
||||||
end
|
|
||||||
if v.protocol and v.protocol == "_balancing" then
|
|
||||||
balancing_list[#balancing_list + 1] = v
|
|
||||||
end
|
|
||||||
if v.protocol and v.protocol == "_shunt" then
|
|
||||||
shunt_list[#shunt_list + 1] = v
|
|
||||||
end
|
|
||||||
if v.protocol and v.protocol == "_iface" then
|
|
||||||
iface_list[#iface_list + 1] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local function get_cfgvalue(shunt_node_id, option)
|
local function get_cfgvalue(shunt_node_id, option)
|
||||||
return function(self, section)
|
return function(self, section)
|
||||||
return m:get(shunt_node_id, option) or "nil"
|
return m:get(shunt_node_id, option) or "nil"
|
||||||
@ -133,8 +139,11 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
|
|||||||
o.cfgvalue = get_cfgvalue(v.id, "preproxy_enabled")
|
o.cfgvalue = get_cfgvalue(v.id, "preproxy_enabled")
|
||||||
o.write = get_write(v.id, "preproxy_enabled")
|
o.write = get_write(v.id, "preproxy_enabled")
|
||||||
|
|
||||||
o = s:taboption("Main", Value, vid .. "-main_node", string.format('<a style="color:red">%s</a>', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including <code>Default</code>) has a separate switch that controls whether this rule uses the pre-proxy or not."))
|
o = s:taboption("Main", ListValue, vid .. "-main_node", string.format('<a style="color:red">%s</a>', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including <code>Default</code>) has a separate switch that controls whether this rule uses the pre-proxy or not."))
|
||||||
o:depends(vid .. "-preproxy_enabled", "1")
|
o:depends(vid .. "-preproxy_enabled", "1")
|
||||||
|
for k1, v1 in pairs(socks_list) do
|
||||||
|
o:value(v1.id, v1.remark)
|
||||||
|
end
|
||||||
for k1, v1 in pairs(balancing_list) do
|
for k1, v1 in pairs(balancing_list) do
|
||||||
o:value(v1.id, v1.remark)
|
o:value(v1.id, v1.remark)
|
||||||
end
|
end
|
||||||
@ -157,7 +166,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
|
|||||||
local id = e[".name"]
|
local id = e[".name"]
|
||||||
local node_option = vid .. "-" .. id .. "_node"
|
local node_option = vid .. "-" .. id .. "_node"
|
||||||
if id and e.remarks then
|
if id and e.remarks then
|
||||||
o = s:taboption("Main", Value, node_option, string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", id), e.remarks))
|
o = s:taboption("Main", ListValue, node_option, string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", id), e.remarks))
|
||||||
o.cfgvalue = get_cfgvalue(v.id, id)
|
o.cfgvalue = get_cfgvalue(v.id, id)
|
||||||
o.write = get_write(v.id, id)
|
o.write = get_write(v.id, id)
|
||||||
o:depends("tcp_node", v.id)
|
o:depends("tcp_node", v.id)
|
||||||
@ -172,6 +181,9 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
|
|||||||
pt:value("nil", translate("Close"))
|
pt:value("nil", translate("Close"))
|
||||||
pt:value("main", translate("Preproxy Node"))
|
pt:value("main", translate("Preproxy Node"))
|
||||||
pt.default = "nil"
|
pt.default = "nil"
|
||||||
|
for k1, v1 in pairs(socks_list) do
|
||||||
|
o:value(v1.id, v1.remark)
|
||||||
|
end
|
||||||
for k1, v1 in pairs(balancing_list) do
|
for k1, v1 in pairs(balancing_list) do
|
||||||
o:value(v1.id, v1.remark)
|
o:value(v1.id, v1.remark)
|
||||||
end
|
end
|
||||||
@ -186,12 +198,15 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
local id = "default_node"
|
local id = "default_node"
|
||||||
o = s:taboption("Main", Value, vid .. "-" .. id, string.format('* <a style="color:red">%s</a>', translate("Default")))
|
o = s:taboption("Main", ListValue, vid .. "-" .. id, string.format('* <a style="color:red">%s</a>', translate("Default")))
|
||||||
o.cfgvalue = get_cfgvalue(v.id, id)
|
o.cfgvalue = get_cfgvalue(v.id, id)
|
||||||
o.write = get_write(v.id, id)
|
o.write = get_write(v.id, id)
|
||||||
o:depends("tcp_node", v.id)
|
o:depends("tcp_node", v.id)
|
||||||
o:value("_direct", translate("Direct Connection"))
|
o:value("_direct", translate("Direct Connection"))
|
||||||
o:value("_blackhole", translate("Blackhole"))
|
o:value("_blackhole", translate("Blackhole"))
|
||||||
|
for k1, v1 in pairs(socks_list) do
|
||||||
|
o:value(v1.id, v1.remark)
|
||||||
|
end
|
||||||
for k1, v1 in pairs(balancing_list) do
|
for k1, v1 in pairs(balancing_list) do
|
||||||
o:value(v1.id, v1.remark)
|
o:value(v1.id, v1.remark)
|
||||||
end
|
end
|
||||||
@ -293,7 +308,7 @@ o.write = function(self, section, value)
|
|||||||
end
|
end
|
||||||
|
|
||||||
o = s:taboption("DNS", Value, "socks_server", translate("Socks Server"), translate("Make sure socks service is available on this address."))
|
o = s:taboption("DNS", Value, "socks_server", translate("Socks Server"), translate("Make sure socks service is available on this address."))
|
||||||
for k, v in pairs(socks_table) do o:value(v.id, v.remarks) end
|
for k, v in pairs(socks_table) do o:value(v.id, v.remark) end
|
||||||
o.default = socks_table[1].id
|
o.default = socks_table[1].id
|
||||||
o.validate = function(self, value, t)
|
o.validate = function(self, value, t)
|
||||||
if not datatypes.ipaddrport(value) then
|
if not datatypes.ipaddrport(value) then
|
||||||
|
@ -54,28 +54,38 @@ for k, e in ipairs(api.get_valid_nodes()) do
|
|||||||
if e.node_type == "normal" then
|
if e.node_type == "normal" then
|
||||||
nodes_table[#nodes_table + 1] = {
|
nodes_table[#nodes_table + 1] = {
|
||||||
id = e[".name"],
|
id = e[".name"],
|
||||||
remarks = e["remark"],
|
remark = e["remark"],
|
||||||
type = e["type"]
|
type = e["type"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if e.protocol == "_balancing" then
|
if e.protocol == "_balancing" then
|
||||||
balancers_table[#balancers_table + 1] = {
|
balancers_table[#balancers_table + 1] = {
|
||||||
id = e[".name"],
|
id = e[".name"],
|
||||||
remarks = e["remark"]
|
remark = e["remark"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if e.protocol == "_iface" then
|
if e.protocol == "_iface" then
|
||||||
iface_table[#iface_table + 1] = {
|
iface_table[#iface_table + 1] = {
|
||||||
id = e[".name"],
|
id = e[".name"],
|
||||||
remarks = e["remark"]
|
remark = e["remark"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local socks_list = {}
|
||||||
|
uci:foreach(appname, "socks", function(s)
|
||||||
|
if s.enabled == "1" and s.node then
|
||||||
|
socks_list[#socks_list + 1] = {
|
||||||
|
id = "Socks_" .. s[".name"],
|
||||||
|
remark = translate("Socks Config") .. " " .. string.format("[%s %s]", s.port, translate("Port"))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- 负载均衡列表
|
-- 负载均衡列表
|
||||||
local o = s:option(DynamicList, option_name("balancing_node"), translate("Load balancing node list"), translate("Load balancing node list, <a target='_blank' href='https://toutyrater.github.io/routing/balance2.html'>document</a>"))
|
local o = s:option(DynamicList, option_name("balancing_node"), translate("Load balancing node list"), translate("Load balancing node list, <a target='_blank' href='https://toutyrater.github.io/routing/balance2.html'>document</a>"))
|
||||||
o:depends({ [option_name("protocol")] = "_balancing" })
|
o:depends({ [option_name("protocol")] = "_balancing" })
|
||||||
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
|
for k, v in pairs(nodes_table) do o:value(v.id, v.remark) end
|
||||||
|
|
||||||
local o = s:option(ListValue, option_name("balancingStrategy"), translate("Balancing Strategy"))
|
local o = s:option(ListValue, option_name("balancingStrategy"), translate("Balancing Strategy"))
|
||||||
o:depends({ [option_name("protocol")] = "_balancing" })
|
o:depends({ [option_name("protocol")] = "_balancing" })
|
||||||
@ -106,22 +116,25 @@ if #nodes_table > 0 then
|
|||||||
o = s:option(Flag, option_name("preproxy_enabled"), translate("Preproxy"))
|
o = s:option(Flag, option_name("preproxy_enabled"), translate("Preproxy"))
|
||||||
o:depends({ [option_name("protocol")] = "_shunt" })
|
o:depends({ [option_name("protocol")] = "_shunt" })
|
||||||
|
|
||||||
o = s:option(Value, option_name("main_node"), string.format('<a style="color:red">%s</a>', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including <code>Default</code>) has a separate switch that controls whether this rule uses the pre-proxy or not."))
|
o = s:option(ListValue, option_name("main_node"), string.format('<a style="color:red">%s</a>', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including <code>Default</code>) has a separate switch that controls whether this rule uses the pre-proxy or not."))
|
||||||
o:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true })
|
o:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true })
|
||||||
|
for k, v in pairs(socks_list) do
|
||||||
|
o:value(v.id, v.remark)
|
||||||
|
end
|
||||||
for k, v in pairs(balancers_table) do
|
for k, v in pairs(balancers_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
for k, v in pairs(iface_table) do
|
for k, v in pairs(iface_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
for k, v in pairs(nodes_table) do
|
for k, v in pairs(nodes_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
o.default = "nil"
|
o.default = "nil"
|
||||||
end
|
end
|
||||||
uci:foreach(appname, "shunt_rules", function(e)
|
uci:foreach(appname, "shunt_rules", function(e)
|
||||||
if e[".name"] and e.remarks then
|
if e[".name"] and e.remarks then
|
||||||
o = s:option(Value, option_name(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks))
|
o = s:option(ListValue, option_name(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks))
|
||||||
o:value("nil", translate("Close"))
|
o:value("nil", translate("Close"))
|
||||||
o:value("_default", translate("Default"))
|
o:value("_default", translate("Default"))
|
||||||
o:value("_direct", translate("Direct Connection"))
|
o:value("_direct", translate("Direct Connection"))
|
||||||
@ -129,18 +142,21 @@ uci:foreach(appname, "shunt_rules", function(e)
|
|||||||
o:depends({ [option_name("protocol")] = "_shunt" })
|
o:depends({ [option_name("protocol")] = "_shunt" })
|
||||||
|
|
||||||
if #nodes_table > 0 then
|
if #nodes_table > 0 then
|
||||||
|
for k, v in pairs(socks_list) do
|
||||||
|
o:value(v.id, v.remark)
|
||||||
|
end
|
||||||
for k, v in pairs(balancers_table) do
|
for k, v in pairs(balancers_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
for k, v in pairs(iface_table) do
|
for k, v in pairs(iface_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
local pt = s:option(ListValue, option_name(e[".name"] .. "_proxy_tag"), string.format('* <a style="color:red">%s</a>', e.remarks .. " " .. translate("Preproxy")))
|
local pt = s:option(ListValue, option_name(e[".name"] .. "_proxy_tag"), string.format('* <a style="color:red">%s</a>', e.remarks .. " " .. translate("Preproxy")))
|
||||||
pt:value("nil", translate("Close"))
|
pt:value("nil", translate("Close"))
|
||||||
pt:value("main", translate("Preproxy Node"))
|
pt:value("main", translate("Preproxy Node"))
|
||||||
pt.default = "nil"
|
pt.default = "nil"
|
||||||
for k, v in pairs(nodes_table) do
|
for k, v in pairs(nodes_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
pt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name(e[".name"])] = v.id })
|
pt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name(e[".name"])] = v.id })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -155,24 +171,27 @@ o.cfgvalue = function(t, n)
|
|||||||
end
|
end
|
||||||
o:depends({ [option_name("protocol")] = "_shunt" })
|
o:depends({ [option_name("protocol")] = "_shunt" })
|
||||||
|
|
||||||
local o = s:option(Value, option_name("default_node"), string.format('* <a style="color:red">%s</a>', translate("Default")))
|
local o = s:option(ListValue, option_name("default_node"), string.format('* <a style="color:red">%s</a>', translate("Default")))
|
||||||
o:depends({ [option_name("protocol")] = "_shunt" })
|
o:depends({ [option_name("protocol")] = "_shunt" })
|
||||||
o:value("_direct", translate("Direct Connection"))
|
o:value("_direct", translate("Direct Connection"))
|
||||||
o:value("_blackhole", translate("Blackhole"))
|
o:value("_blackhole", translate("Blackhole"))
|
||||||
|
|
||||||
if #nodes_table > 0 then
|
if #nodes_table > 0 then
|
||||||
|
for k, v in pairs(socks_list) do
|
||||||
|
o:value(v.id, v.remark)
|
||||||
|
end
|
||||||
for k, v in pairs(balancers_table) do
|
for k, v in pairs(balancers_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
for k, v in pairs(iface_table) do
|
for k, v in pairs(iface_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
local dpt = s:option(ListValue, option_name("default_proxy_tag"), string.format('* <a style="color:red">%s</a>', translate("Default Preproxy")), translate("When using, localhost will connect this node first and then use this node to connect the default node."))
|
local dpt = s:option(ListValue, option_name("default_proxy_tag"), string.format('* <a style="color:red">%s</a>', translate("Default Preproxy")), translate("When using, localhost will connect this node first and then use this node to connect the default node."))
|
||||||
dpt:value("nil", translate("Close"))
|
dpt:value("nil", translate("Close"))
|
||||||
dpt:value("main", translate("Preproxy Node"))
|
dpt:value("main", translate("Preproxy Node"))
|
||||||
dpt.default = "nil"
|
dpt.default = "nil"
|
||||||
for k, v in pairs(nodes_table) do
|
for k, v in pairs(nodes_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
dpt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name("default_node")] = v.id })
|
dpt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name("default_node")] = v.id })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -528,7 +547,7 @@ o.default = ""
|
|||||||
o:value("", translate("Close(Not use)"))
|
o:value("", translate("Close(Not use)"))
|
||||||
for k, v in pairs(nodes_table) do
|
for k, v in pairs(nodes_table) do
|
||||||
if v.type == "Xray" then
|
if v.type == "Xray" then
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -70,36 +70,49 @@ for k, e in ipairs(api.get_valid_nodes()) do
|
|||||||
if e.node_type == "normal" then
|
if e.node_type == "normal" then
|
||||||
nodes_table[#nodes_table + 1] = {
|
nodes_table[#nodes_table + 1] = {
|
||||||
id = e[".name"],
|
id = e[".name"],
|
||||||
remarks = e["remark"],
|
remark = e["remark"],
|
||||||
type = e["type"]
|
type = e["type"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
if e.protocol == "_iface" then
|
if e.protocol == "_iface" then
|
||||||
iface_table[#iface_table + 1] = {
|
iface_table[#iface_table + 1] = {
|
||||||
id = e[".name"],
|
id = e[".name"],
|
||||||
remarks = e["remark"]
|
remark = e["remark"]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local socks_list = {}
|
||||||
|
uci:foreach(appname, "socks", function(s)
|
||||||
|
if s.enabled == "1" and s.node then
|
||||||
|
socks_list[#socks_list + 1] = {
|
||||||
|
id = "Socks_" .. s[".name"],
|
||||||
|
remark = translate("Socks Config") .. " " .. string.format("[%s %s]", s.port, translate("Port"))
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- [[ 分流模块 ]]
|
-- [[ 分流模块 ]]
|
||||||
if #nodes_table > 0 then
|
if #nodes_table > 0 then
|
||||||
o = s:option(Flag, option_name("preproxy_enabled"), translate("Preproxy"))
|
o = s:option(Flag, option_name("preproxy_enabled"), translate("Preproxy"))
|
||||||
o:depends({ [option_name("protocol")] = "_shunt" })
|
o:depends({ [option_name("protocol")] = "_shunt" })
|
||||||
|
|
||||||
o = s:option(Value, option_name("main_node"), string.format('<a style="color:red">%s</a>', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including <code>Default</code>) has a separate switch that controls whether this rule uses the pre-proxy or not."))
|
o = s:option(ListValue, option_name("main_node"), string.format('<a style="color:red">%s</a>', translate("Preproxy Node")), translate("Set the node to be used as a pre-proxy. Each rule (including <code>Default</code>) has a separate switch that controls whether this rule uses the pre-proxy or not."))
|
||||||
o:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true })
|
o:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true })
|
||||||
|
for k, v in pairs(socks_list) do
|
||||||
|
o:value(v.id, v.remark)
|
||||||
|
end
|
||||||
for k, v in pairs(iface_table) do
|
for k, v in pairs(iface_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
for k, v in pairs(nodes_table) do
|
for k, v in pairs(nodes_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
o.default = "nil"
|
o.default = "nil"
|
||||||
end
|
end
|
||||||
uci:foreach(appname, "shunt_rules", function(e)
|
uci:foreach(appname, "shunt_rules", function(e)
|
||||||
if e[".name"] and e.remarks then
|
if e[".name"] and e.remarks then
|
||||||
o = s:option(Value, option_name(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks))
|
o = s:option(ListValue, option_name(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks))
|
||||||
o:value("nil", translate("Close"))
|
o:value("nil", translate("Close"))
|
||||||
o:value("_default", translate("Default"))
|
o:value("_default", translate("Default"))
|
||||||
o:value("_direct", translate("Direct Connection"))
|
o:value("_direct", translate("Direct Connection"))
|
||||||
@ -107,15 +120,18 @@ uci:foreach(appname, "shunt_rules", function(e)
|
|||||||
o:depends({ [option_name("protocol")] = "_shunt" })
|
o:depends({ [option_name("protocol")] = "_shunt" })
|
||||||
|
|
||||||
if #nodes_table > 0 then
|
if #nodes_table > 0 then
|
||||||
|
for k, v in pairs(socks_list) do
|
||||||
|
o:value(v.id, v.remark)
|
||||||
|
end
|
||||||
for k, v in pairs(iface_table) do
|
for k, v in pairs(iface_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
local pt = s:option(ListValue, option_name(e[".name"] .. "_proxy_tag"), string.format('* <a style="color:red">%s</a>', e.remarks .. " " .. translate("Preproxy")))
|
local pt = s:option(ListValue, option_name(e[".name"] .. "_proxy_tag"), string.format('* <a style="color:red">%s</a>', e.remarks .. " " .. translate("Preproxy")))
|
||||||
pt:value("nil", translate("Close"))
|
pt:value("nil", translate("Close"))
|
||||||
pt:value("main", translate("Preproxy Node"))
|
pt:value("main", translate("Preproxy Node"))
|
||||||
pt.default = "nil"
|
pt.default = "nil"
|
||||||
for k, v in pairs(nodes_table) do
|
for k, v in pairs(nodes_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
pt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name(e[".name"])] = v.id })
|
pt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name(e[".name"])] = v.id })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -130,21 +146,24 @@ o.cfgvalue = function(t, n)
|
|||||||
end
|
end
|
||||||
o:depends({ [option_name("protocol")] = "_shunt" })
|
o:depends({ [option_name("protocol")] = "_shunt" })
|
||||||
|
|
||||||
local o = s:option(Value, option_name("default_node"), string.format('* <a style="color:red">%s</a>', translate("Default")))
|
local o = s:option(ListValue, option_name("default_node"), string.format('* <a style="color:red">%s</a>', translate("Default")))
|
||||||
o:depends({ [option_name("protocol")] = "_shunt" })
|
o:depends({ [option_name("protocol")] = "_shunt" })
|
||||||
o:value("_direct", translate("Direct Connection"))
|
o:value("_direct", translate("Direct Connection"))
|
||||||
o:value("_blackhole", translate("Blackhole"))
|
o:value("_blackhole", translate("Blackhole"))
|
||||||
|
|
||||||
if #nodes_table > 0 then
|
if #nodes_table > 0 then
|
||||||
|
for k, v in pairs(socks_list) do
|
||||||
|
o:value(v.id, v.remark)
|
||||||
|
end
|
||||||
for k, v in pairs(iface_table) do
|
for k, v in pairs(iface_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
local dpt = s:option(ListValue, option_name("default_proxy_tag"), string.format('* <a style="color:red">%s</a>', translate("Default Preproxy")), translate("When using, localhost will connect this node first and then use this node to connect the default node."))
|
local dpt = s:option(ListValue, option_name("default_proxy_tag"), string.format('* <a style="color:red">%s</a>', translate("Default Preproxy")), translate("When using, localhost will connect this node first and then use this node to connect the default node."))
|
||||||
dpt:value("nil", translate("Close"))
|
dpt:value("nil", translate("Close"))
|
||||||
dpt:value("main", translate("Preproxy Node"))
|
dpt:value("main", translate("Preproxy Node"))
|
||||||
dpt.default = "nil"
|
dpt.default = "nil"
|
||||||
for k, v in pairs(nodes_table) do
|
for k, v in pairs(nodes_table) do
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
dpt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name("default_node")] = v.id })
|
dpt:depends({ [option_name("protocol")] = "_shunt", [option_name("preproxy_enabled")] = true, [option_name("default_node")] = v.id })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -627,7 +646,7 @@ o.default = ""
|
|||||||
o:value("", translate("Close(Not use)"))
|
o:value("", translate("Close(Not use)"))
|
||||||
for k, v in pairs(nodes_table) do
|
for k, v in pairs(nodes_table) do
|
||||||
if v.type == "sing-box" then
|
if v.type == "sing-box" then
|
||||||
o:value(v.id, v.remarks)
|
o:value(v.id, v.remark)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i, v in ipairs(s.fields[option_name("protocol")].keylist) do
|
for i, v in ipairs(s.fields[option_name("protocol")].keylist) do
|
||||||
|
@ -930,22 +930,23 @@ function gen_config(var)
|
|||||||
local preproxy_node_id = node["main_node"]
|
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_node = preproxy_enabled and preproxy_node_id and uci:get_all(appname, preproxy_node_id) or nil
|
||||||
|
|
||||||
if not preproxy_node and preproxy_node_id and api.parseURL(preproxy_node_id) then
|
if preproxy_node_id and preproxy_node_id:find("Socks_") then
|
||||||
local parsed1 = api.parseURL(preproxy_node_id)
|
local socks_id = preproxy_node_id:sub(1 + #"Socks_")
|
||||||
local _node = {
|
local socks_node = uci:get_all(appname, socks_id) or nil
|
||||||
type = "sing-box",
|
if socks_node then
|
||||||
protocol = parsed1.protocol,
|
local _node = {
|
||||||
username = parsed1.username,
|
type = "sing-box",
|
||||||
password = parsed1.password,
|
protocol = "socks",
|
||||||
address = parsed1.host,
|
address = "127.0.0.1",
|
||||||
port = parsed1.port,
|
port = socks_node.port,
|
||||||
uot = "1",
|
uot = "1",
|
||||||
}
|
}
|
||||||
local preproxy_outbound = gen_outbound(flag, _node, preproxy_tag)
|
local preproxy_outbound = gen_outbound(flag, _node, preproxy_tag)
|
||||||
if preproxy_outbound then
|
if preproxy_outbound then
|
||||||
table.insert(outbounds, preproxy_outbound)
|
table.insert(outbounds, preproxy_outbound)
|
||||||
else
|
else
|
||||||
preproxy_enabled = false
|
preproxy_enabled = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif preproxy_node and api.is_normal_node(preproxy_node) then
|
elseif preproxy_node and api.is_normal_node(preproxy_node) then
|
||||||
local preproxy_outbound = gen_outbound(flag, preproxy_node, preproxy_tag)
|
local preproxy_outbound = gen_outbound(flag, preproxy_node, preproxy_tag)
|
||||||
@ -967,21 +968,22 @@ function gen_config(var)
|
|||||||
rule_outboundTag = "block"
|
rule_outboundTag = "block"
|
||||||
elseif _node_id == "_default" and rule_name ~= "default" then
|
elseif _node_id == "_default" and rule_name ~= "default" then
|
||||||
rule_outboundTag = "default"
|
rule_outboundTag = "default"
|
||||||
elseif api.parseURL(_node_id) then
|
elseif _node_id:find("Socks_") then
|
||||||
local parsed1 = api.parseURL(_node_id)
|
local socks_id = _node_id:sub(1 + #"Socks_")
|
||||||
local _node = {
|
local socks_node = uci:get_all(appname, socks_id) or nil
|
||||||
type = "sing-box",
|
if socks_node then
|
||||||
protocol = parsed1.protocol,
|
local _node = {
|
||||||
username = parsed1.username,
|
type = "sing-box",
|
||||||
password = parsed1.password,
|
protocol = "socks",
|
||||||
address = parsed1.host,
|
address = "127.0.0.1",
|
||||||
port = parsed1.port,
|
port = socks_node.port,
|
||||||
uot = "1",
|
uot = "1",
|
||||||
}
|
}
|
||||||
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
|
rule_outboundTag = rule_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif _node_id ~= "nil" then
|
elseif _node_id ~= "nil" then
|
||||||
local _node = uci:get_all(appname, _node_id)
|
local _node = uci:get_all(appname, _node_id)
|
||||||
|
@ -742,23 +742,24 @@ function gen_config(var)
|
|||||||
local preproxy_node = preproxy_enabled and preproxy_node_id and uci:get_all(appname, preproxy_node_id) or nil
|
local preproxy_node = preproxy_enabled and preproxy_node_id and uci:get_all(appname, preproxy_node_id) or nil
|
||||||
local preproxy_is_balancer
|
local preproxy_is_balancer
|
||||||
|
|
||||||
if not preproxy_node and preproxy_node_id and api.parseURL(preproxy_node_id) then
|
if preproxy_node_id and preproxy_node_id:find("Socks_") then
|
||||||
local parsed1 = api.parseURL(preproxy_node_id)
|
local socks_id = preproxy_node_id:sub(1 + #"Socks_")
|
||||||
local _node = {
|
local socks_node = uci:get_all(appname, socks_id) or nil
|
||||||
type = "Xray",
|
if socks_node then
|
||||||
protocol = parsed1.protocol,
|
local _node = {
|
||||||
username = parsed1.username,
|
type = "Xray",
|
||||||
password = parsed1.password,
|
protocol = "socks",
|
||||||
address = parsed1.host,
|
address = "127.0.0.1",
|
||||||
port = parsed1.port,
|
port = socks_node.port,
|
||||||
transport = "tcp",
|
transport = "tcp",
|
||||||
stream_security = "none"
|
stream_security = "none"
|
||||||
}
|
}
|
||||||
local preproxy_outbound = gen_outbound(flag, _node, preproxy_tag)
|
local preproxy_outbound = gen_outbound(flag, _node, preproxy_tag)
|
||||||
if preproxy_outbound then
|
if preproxy_outbound then
|
||||||
table.insert(outbounds, preproxy_outbound)
|
table.insert(outbounds, preproxy_outbound)
|
||||||
else
|
else
|
||||||
preproxy_enabled = false
|
preproxy_enabled = false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif preproxy_node and api.is_normal_node(preproxy_node) then
|
elseif preproxy_node and api.is_normal_node(preproxy_node) then
|
||||||
local preproxy_outbound = gen_outbound(flag, preproxy_node, preproxy_tag, { fragment = xray_settings.fragment == "1" or nil })
|
local preproxy_outbound = gen_outbound(flag, preproxy_node, preproxy_tag, { fragment = xray_settings.fragment == "1" or nil })
|
||||||
@ -790,22 +791,23 @@ function gen_config(var)
|
|||||||
rule_outboundTag = "blackhole"
|
rule_outboundTag = "blackhole"
|
||||||
elseif _node_id == "_default" and rule_name ~= "default" then
|
elseif _node_id == "_default" and rule_name ~= "default" then
|
||||||
rule_outboundTag = "default"
|
rule_outboundTag = "default"
|
||||||
elseif api.parseURL(_node_id) then
|
elseif _node_id:find("Socks_") then
|
||||||
local parsed1 = api.parseURL(_node_id)
|
local socks_id = _node_id:sub(1 + #"Socks_")
|
||||||
local _node = {
|
local socks_node = uci:get_all(appname, socks_id) or nil
|
||||||
type = "Xray",
|
if socks_node then
|
||||||
protocol = parsed1.protocol,
|
local _node = {
|
||||||
username = parsed1.username,
|
type = "Xray",
|
||||||
password = parsed1.password,
|
protocol = "socks",
|
||||||
address = parsed1.host,
|
address = "127.0.0.1",
|
||||||
port = parsed1.port,
|
port = socks_node.port,
|
||||||
transport = "tcp",
|
transport = "tcp",
|
||||||
stream_security = "none"
|
stream_security = "none"
|
||||||
}
|
}
|
||||||
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
|
rule_outboundTag = rule_name
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif _node_id ~= "nil" then
|
elseif _node_id ~= "nil" then
|
||||||
local _node = uci:get_all(appname, _node_id)
|
local _node = uci:get_all(appname, _node_id)
|
||||||
|
@ -53,7 +53,7 @@ local api = require "luci.passwall.api"
|
|||||||
var dom_id = dom.id.split(cbi_id).join(cbi_id.split("-").join(".")).split("cbi.").join("cbid.")
|
var dom_id = dom.id.split(cbi_id).join(cbi_id.split("-").join(".")).split("cbi.").join("cbid.")
|
||||||
var node_select = document.getElementsByName(dom_id)[0];
|
var node_select = document.getElementsByName(dom_id)[0];
|
||||||
var node_select_value = node_select.value;
|
var node_select_value = node_select.value;
|
||||||
if (node_select_value && node_select_value != "nil" && node_select_value.indexOf("socks://") != 0 && node_select_value.indexOf("_default") != 0 && node_select_value.indexOf("_direct") != 0 && node_select_value.indexOf("_blackhole") != 0) {
|
if (node_select_value && node_select_value != "nil" && node_select_value.indexOf("_default") != 0 && node_select_value.indexOf("_direct") != 0 && node_select_value.indexOf("_blackhole") != 0) {
|
||||||
if (global_id != null && node_select_value.indexOf("tcp") == 0) {
|
if (global_id != null && node_select_value.indexOf("tcp") == 0) {
|
||||||
var d = global_id + "-tcp_node";
|
var d = global_id + "-tcp_node";
|
||||||
d = d.replace("cbi-", "cbid-").replace(new RegExp("-", 'g'), ".");
|
d = d.replace("cbi-", "cbid-").replace(new RegExp("-", 'g'), ".");
|
||||||
@ -68,11 +68,18 @@ local api = require "luci.passwall.api"
|
|||||||
node_select = document.getElementById("cbi.combobox." + dom_id);
|
node_select = document.getElementById("cbi.combobox." + dom_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
var new_a = document.createElement("a");
|
var new_html = ""
|
||||||
new_a.innerHTML = "<%:Edit%>";
|
if (true) {
|
||||||
new_a.href = "#";
|
var to_url = '<%=api.url("node_config")%>/' + node_select_value;
|
||||||
new_a.setAttribute("onclick", "location.href='" + '<%=api.url("node_config")%>' + "/" + node_select_value + "'");
|
if (node_select_value.indexOf("Socks_") == 0) {
|
||||||
var new_html = new_a.outerHTML;
|
to_url = '<%=api.url("socks_config")%>/' + node_select_value.substring("Socks_".length);
|
||||||
|
}
|
||||||
|
var new_a = document.createElement("a");
|
||||||
|
new_a.innerHTML = "<%:Edit%>";
|
||||||
|
new_a.href = "#";
|
||||||
|
new_a.setAttribute("onclick", "location.href='" + to_url + "'");
|
||||||
|
new_html = new_a.outerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
if (s[0] == "tcp" || s[0] == "udp") {
|
if (s[0] == "tcp" || s[0] == "udp") {
|
||||||
var log_a = document.createElement("a");
|
var log_a = document.createElement("a");
|
||||||
|
Loading…
Reference in New Issue
Block a user