luci: shunt rule add inboundTag option

This commit is contained in:
xiaorouji 2023-11-25 02:12:35 +08:00 committed by sbwml
parent c723875552
commit 40caf0ed97
4 changed files with 52 additions and 0 deletions

View File

@ -18,6 +18,10 @@ protocol:value("http")
protocol:value("tls")
protocol:value("bittorrent")
o = s:option(MultiValue, "inbound", translate("Inbound Tag"))
o:value("tproxy", translate("Transparent proxy"))
o:value("socks", "Socks")
network = s:option(ListValue, "network", translate("Network"))
network:value("tcp,udp", "TCP UDP")
network:value("tcp", "TCP")

View File

@ -1052,8 +1052,31 @@ function gen_config(var)
table.insert(protocols, w)
end)
end
local inboundTag = nil
if e["inbound"] and e["inbound"] ~= "" then
inboundTag = {}
if e["inbound"]:find("tproxy") then
if tcp_redir_port then
if tcp_proxy_way == "tproxy" then
table.insert(inboundTag, "tproxy_tcp")
else
table.insert(inboundTag, "redirect_tcp")
end
end
if udp_redir_port then
table.insert(inboundTag, "tproxy_udp")
end
end
if e["inbound"]:find("socks") then
if local_socks_port then
table.insert(inboundTag, "socks-in")
end
end
end
local rule = {
inbound = inboundTag,
outbound = outboundTag,
invert = false, --匹配反选
protocol = protocols

View File

@ -547,6 +547,7 @@ function gen_config(var)
local node = uci:get_all(appname, node_id)
if local_socks_port then
local inbound = {
tag = "socks-in",
listen = local_socks_address,
port = tonumber(local_socks_port),
protocol = "socks",
@ -870,6 +871,23 @@ function gen_config(var)
table.insert(protocols, w)
end)
end
local inboundTag = nil
if e["inbound"] and e["inbound"] ~= "" then
inboundTag = {}
if e["inbound"]:find("tproxy") then
if tcp_redir_port then
table.insert(inboundTag, "tcp_redir")
end
if udp_redir_port then
table.insert(inboundTag, "udp_redir")
end
end
if e["inbound"]:find("socks") then
if local_socks_port then
table.insert(inboundTag, "socks-in")
end
end
end
local domains = nil
if e.domain_list then
domains = {}
@ -894,6 +912,7 @@ function gen_config(var)
local rule = {
_flag = e.remarks,
type = "field",
inboundTag = inboundTag,
outboundTag = outboundTag,
balancerTag = balancerTag,
network = e["network"] or "tcp,udp",

View File

@ -1018,6 +1018,12 @@ msgstr "配置路由etc/hosts文件如果你不知道自己在做什么
msgid "These had been joined ip addresses will be block. Please input the ip address or ip address segment, every line can input only one ip address."
msgstr "加入的IP段将屏蔽。可输入IP地址或地址段每个地址段一行。"
msgid "Inbound Tag"
msgstr "入站标签"
msgid "Transparent proxy"
msgstr "透明代理"
msgid "Not valid domain name, please re-enter!"
msgstr "不是有效域名,请重新输入!"