From 549c8735f5741d4d2ca14a7d0bb187ddfa910fb7 Mon Sep 17 00:00:00 2001 From: xiaorouji <60100640+xiaorouji@users.noreply.github.com> Date: Thu, 5 Jan 2023 13:35:05 +0800 Subject: [PATCH] luci: add Xray dialerProxy option --- .../model/cbi/passwall/api/gen_v2ray.lua | 29 +++++++++++++------ .../model/cbi/passwall/client/node_config.lua | 3 ++ luci-app-passwall/po/zh-cn/passwall.po | 3 ++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua b/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua index 9daef4996..b54b55b11 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_v2ray.lua @@ -71,9 +71,11 @@ end function gen_outbound(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 if node and node ~= "nil" then @@ -85,10 +87,18 @@ function gen_outbound(node, tag, proxy_table) if node.type == "V2ray" or node.type == "Xray" then proxy = 0 if proxy_tag ~= "nil" then - node.proxySettings = { - tag = proxy_tag, - transportLayer = true - } + if dialerProxy and dialerProxy == "1" then + node.streamSettings = { + sockopt = { + dialerProxy = proxy_tag + } + } + else + node.proxySettings = { + tag = proxy_tag, + transportLayer = true + } + end end end @@ -107,7 +117,7 @@ function gen_outbound(node, tag, proxy_table) "127.0.0.1", --bind new_port, --socks port string.format("%s_%s_%s_%s.json", flag, tag, node_id, new_port), --config file - (proxy == 1 and proxy_tag ~= "nil" and relay_port) and tostring(relay_port) or "" --relay port + (proxy == 1 and relay_port) and tostring(relay_port) or "" --relay port ) ) ) @@ -139,9 +149,10 @@ function gen_outbound(node, tag, proxy_table) concurrency = (node.mux_concurrency) and tonumber(node.mux_concurrency) or 8 } or nil, -- 底层传输配置 - streamSettings = (node.protocol == "vmess" or node.protocol == "vless" or node.protocol == "socks" or node.protocol == "shadowsocks" or node.protocol == "trojan") and { + streamSettings = (node.streamSettings or node.protocol == "vmess" or node.protocol == "vless" or node.protocol == "socks" or node.protocol == "shadowsocks" or node.protocol == "trojan") and { sockopt = { - mark = 255 + mark = 255, + dialerProxy = (node.streamSettings and dialerProxy and dialerProxy == "1") and node.streamSettings.sockopt.dialerProxy or nil }, network = node.transport, security = node.stream_security, @@ -382,7 +393,7 @@ if node_id then end end if default_node and api.is_normal_node(default_node) then - local default_outbound = gen_outbound(default_node, "default", { proxy = proxy, tag = proxy_tag }) + local default_outbound = gen_outbound(default_node, "default", { proxy = proxy, tag = proxy_tag, dialerProxy = node.dialerProxy }) if default_outbound then table.insert(outbounds, default_outbound) default_outboundTag = "default" @@ -440,7 +451,7 @@ if node_id then }) end end - local _outbound = gen_outbound(_node, name, { proxy = (proxy_tag ~= "nil") and 1 or 0, tag = (proxy_tag ~= "nil") and proxy_tag or nil }) + local _outbound = gen_outbound(_node, name, { proxy = (proxy_tag ~= "nil") and 1 or 0, tag = (proxy_tag ~= "nil") and proxy_tag or nil, dialerProxy = node.dialerProxy }) if _outbound then table.insert(outbounds, _outbound) outboundTag = name diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua index 01430b41d..ed20a0353 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua @@ -188,6 +188,9 @@ if #nodes_table > 0 then end end +dialerProxy = s:option(Flag, "dialerProxy", translate("dialerProxy")) +dialerProxy:depends({ type = "Xray", protocol = "_shunt"}) + domainStrategy = s:option(ListValue, "domainStrategy", translate("Domain Strategy")) domainStrategy:value("AsIs") domainStrategy:value("IPIfNonMatch") diff --git a/luci-app-passwall/po/zh-cn/passwall.po b/luci-app-passwall/po/zh-cn/passwall.po index e8185ebf3..bf41b8ee7 100644 --- a/luci-app-passwall/po/zh-cn/passwall.po +++ b/luci-app-passwall/po/zh-cn/passwall.po @@ -367,6 +367,9 @@ msgstr "没有分流规则?点我前往去添加。" msgid "When using, localhost will connect this node first and then use this node to connect the default node." msgstr "当使用时,本机将首先连接到此节点,然后再使用此节点连接到默认节点落地。" +msgid "dialerProxy" +msgstr "底层传输方式的链式转发" + msgid "Domain Strategy" msgstr "域名解析策略"