luci: achieve Xray vision pre-proxy

This commit is contained in:
xiaorouji 2023-03-13 02:49:22 +08:00 committed by sbwml
parent 2fc4eb5470
commit 12976f60a3
2 changed files with 42 additions and 22 deletions

View File

@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall PKG_NAME:=luci-app-passwall
PKG_VERSION:=4.60 PKG_VERSION:=4.60
PKG_RELEASE:=2 PKG_RELEASE:=4
PKG_CONFIG_DEPENDS:= \ PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \

View File

@ -33,14 +33,6 @@ local function get_domain_excluded()
end end
function gen_outbound(flag, node, tag, proxy_table) function gen_outbound(flag, node, tag, proxy_table)
local proxy = 0
local proxy_tag = "nil"
local dialerProxy = nil
if proxy_table ~= nil and type(proxy_table) == "table" then
proxy = proxy_table.proxy or 0
proxy_tag = proxy_table.tag or "nil"
dialerProxy = proxy_table.dialerProxy
end
local result = nil local result = nil
if node and node ~= "nil" then if node and node ~= "nil" then
local node_id = node[".name"] local node_id = node[".name"]
@ -48,20 +40,32 @@ function gen_outbound(flag, node, tag, proxy_table)
tag = node_id tag = node_id
end end
local proxy = 0
local proxy_tag = "nil"
local dialerProxy = nil
if proxy_table ~= nil and type(proxy_table) == "table" then
proxy = proxy_table.proxy or 0
proxy_tag = proxy_table.tag or "nil"
dialerProxy = proxy_table.dialerProxy
end
if node.type == "V2ray" or node.type == "Xray" then if node.type == "V2ray" or node.type == "Xray" then
proxy = 0 if node.type == "Xray" and node.tlsflow == "xtls-rprx-vision" then
if proxy_tag ~= "nil" then else
if dialerProxy and dialerProxy == "1" then proxy = 0
node.streamSettings = { if proxy_tag ~= "nil" then
sockopt = { if dialerProxy and dialerProxy == "1" then
dialerProxy = proxy_tag node.streamSettings = {
sockopt = {
dialerProxy = proxy_tag
}
} }
} else
else node.proxySettings = {
node.proxySettings = { tag = proxy_tag,
tag = proxy_tag, transportLayer = true
transportLayer = true }
} end
end end
end end
end end
@ -96,7 +100,9 @@ function gen_outbound(flag, node, tag, proxy_table)
node.port = new_port node.port = new_port
end end
node.stream_security = "none" node.stream_security = "none"
else end
if node.type == "V2ray" or node.type == "Xray" then
if node.tls and node.tls == "1" then if node.tls and node.tls == "1" then
node.stream_security = "tls" node.stream_security = "tls"
if node.type == "Xray" and node.reality and node.reality == "1" then if node.type == "Xray" and node.reality and node.reality == "1" then
@ -611,7 +617,14 @@ function gen_config(var)
table.insert(outbounds, main_node_outbound) table.insert(outbounds, main_node_outbound)
proxy = 1 proxy = 1
proxy_tag = "main" proxy_tag = "main"
local pre_proxy = nil
if default_node.type ~= "V2ray" and default_node.type ~= "Xray" then if default_node.type ~= "V2ray" and default_node.type ~= "Xray" then
pre_proxy = true
end
if default_node.type == "Xray" and default_node.tlsflow == "xtls-rprx-vision" then
pre_proxy = true
end
if pre_proxy then
proxy_tag = nil proxy_tag = nil
new_port = get_new_port() new_port = get_new_port()
table.insert(inbounds, { table.insert(inbounds, {
@ -672,7 +685,14 @@ function gen_config(var)
table.insert(outbounds, new_outbound) table.insert(outbounds, new_outbound)
outboundTag = name outboundTag = name
else else
local pre_proxy = nil
if _node.type ~= "V2ray" and _node.type ~= "Xray" then if _node.type ~= "V2ray" and _node.type ~= "Xray" then
pre_proxy = true
end
if _node.type == "Xray" and _node.tlsflow == "xtls-rprx-vision" then
pre_proxy = true
end
if pre_proxy then
if proxy_tag ~= "nil" then if proxy_tag ~= "nil" then
new_port = get_new_port() new_port = get_new_port()
table.insert(inbounds, { table.insert(inbounds, {