From 8ca42bc0638630b7e84fe69d5cc7434675234b67 Mon Sep 17 00:00:00 2001 From: gitea-action Date: Tue, 19 Nov 2024 23:31:15 +0800 Subject: [PATCH] luci-app-passwall2: sync upstream last commit: https://github.com/xiaorouji/openwrt-passwall2/commit/731102c8c83bc6b664aa1121d33fd4a89fb57bfd --- .../luasrc/passwall2/util_xray.lua | 3 +- .../passwall2/node_list/link_share_man.htm | 28 +++++++++-- .../root/usr/share/passwall2/subscribe.lua | 50 ++++++++++++------- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/luci-app-passwall2/luasrc/passwall2/util_xray.lua b/luci-app-passwall2/luasrc/passwall2/util_xray.lua index ad61cefda..1aa130cb7 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_xray.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_xray.lua @@ -264,7 +264,8 @@ function gen_outbound(flag, node, tag, proxy_table) level = 0, security = (node.protocol == "vmess") and node.security or nil, encryption = node.encryption or "none", - flow = (node.protocol == "vless" and node.tls == "1" and node.transport == "raw" and node.flow and node.flow ~= "") and node.flow or nil + flow = (node.protocol == "vless" and node.tls == "1" and (node.transport == "raw" or node.transport == "tcp") and node.flow and node.flow ~= "") and node.flow or nil + } } } diff --git a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm index 03e6cca6c..292263268 100644 --- a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm @@ -794,6 +794,11 @@ local api = require "luci.passwall2.api" queryParam.type = "mkcp" if (queryParam.type === "h2" || queryParam.type === "http") queryParam.type = "h2" + if (dom_prefix == "singbox_" && queryParam.type === "raw") { + queryParam.type = "tcp"; + } else if (dom_prefix == "xray_" && queryParam.type === "tcp") { + queryParam.type = "raw"; + } opt.set(dom_prefix + 'transport', queryParam.type); if (queryParam.type === "raw" || queryParam.type === "tcp") { opt.set(dom_prefix + 'tcp_guise', queryParam.headerType || "none"); @@ -833,7 +838,7 @@ local api = require "luci.passwall2.api" opt.set(dom_prefix + 'mkcp_guise', queryParam.headerType || "none"); } else if (queryParam.type === "grpc") { opt.set(dom_prefix + 'grpc_serviceName', (queryParam.serviceName || queryParam.path) || ""); - opt.set(dom_prefix + 'grpc_mode', queryParam.mode); + opt.set(dom_prefix + 'grpc_mode', queryParam.mode || "gun"); } } } else { @@ -903,6 +908,11 @@ local api = require "luci.passwall2.api" queryParam.type = "mkcp" if (queryParam.type === "h2" || queryParam.type === "http") queryParam.type = "h2" + if (dom_prefix == "singbox_" && queryParam.type === "raw") { + queryParam.type = "tcp"; + } else if (dom_prefix == "xray_" && queryParam.type === "tcp") { + queryParam.type = "raw"; + } opt.set(dom_prefix + 'transport', queryParam.type); if (queryParam.type === "raw" || queryParam.type === "tcp") { opt.set(dom_prefix + 'tcp_guise', queryParam.headerType || "none"); @@ -942,7 +952,7 @@ local api = require "luci.passwall2.api" opt.set(dom_prefix + 'mkcp_guise', queryParam.headerType || "none"); } else if (queryParam.type === "grpc") { opt.set(dom_prefix + 'grpc_serviceName', (queryParam.serviceName || queryParam.path) || ""); - opt.set(dom_prefix + 'grpc_mode', queryParam.mode); + opt.set(dom_prefix + 'grpc_mode', queryParam.mode || "gun"); } opt.set(dom_prefix + 'mux', queryParam.mux === '1'); @@ -983,8 +993,13 @@ local api = require "luci.passwall2.api" ssm.net = ssm.net.toLowerCase(); if (ssm.net === "kcp" || ssm.net === "mkcp") ssm.net = "mkcp" + if (dom_prefix == "singbox_" && ssm.net === "raw") { + ssm.net = "tcp"; + } else if (dom_prefix == "xray_" && ssm.net === "tcp") { + ssm.net = "raw"; + } opt.set(dom_prefix + 'transport', ssm.net); - if (ssm.net === "raw") { + if (ssm.net === "raw" || ssm.net === "tcp") { opt.set(dom_prefix + 'tcp_guise', (ssm.host && ssm.path) ? "http" : "none"); if (ssm.host && ssm.path) { opt.set(dom_prefix + 'tcp_guise_http_host', ssm.host); @@ -1091,6 +1106,11 @@ local api = require "luci.passwall2.api" queryParam.type = "mkcp" if (queryParam.type === "h2" || queryParam.type === "http") queryParam.type = "h2" + if (dom_prefix == "singbox_" && queryParam.type === "raw") { + queryParam.type = "tcp"; + } else if (dom_prefix == "xray_" && queryParam.type === "tcp") { + queryParam.type = "raw"; + } opt.set(dom_prefix + 'transport', queryParam.type); if (queryParam.type === "raw" || queryParam.type === "tcp") { opt.set(dom_prefix + 'tcp_guise', queryParam.headerType || "none"); @@ -1130,7 +1150,7 @@ local api = require "luci.passwall2.api" opt.set(dom_prefix + 'mkcp_guise', queryParam.headerType || "none"); } else if (queryParam.type === "grpc") { opt.set(dom_prefix + 'grpc_serviceName', (queryParam.serviceName || queryParam.path) || ""); - opt.set(dom_prefix + 'grpc_mode', queryParam.mode); + opt.set(dom_prefix + 'grpc_mode', queryParam.mode || "gun"); } else if (queryParam.type === "xhttp" || queryParam.type === "splithttp") { opt.set(dom_prefix + 'xhttp_host', queryParam.host || ""); opt.set(dom_prefix + 'xhttp_path', queryParam.path || ""); diff --git a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua index 1df45f1da..e1db55600 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua +++ b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua @@ -428,10 +428,13 @@ local function processData(szType, content, add_mode, add_from) -- result.mux = 1 -- result.mux_concurrency = 8 - if not info.net then - info.net = "tcp" - end + if not info.net then info.net = "tcp" end info.net = string.lower(info.net) + if result.type == "sing-box" and info.net == "raw" then + info.net = "tcp" + elseif result.type == "Xray" and info.net == "tcp" then + info.net = "raw" + end result.transport = info.net if info.net == 'ws' then result.ws_host = info.host @@ -495,7 +498,7 @@ local function processData(szType, content, add_mode, add_from) result.tls = "0" end - if result.type == "sing-box" and (result.transport == "mkcp" or result.transport == "xhttp" or result.transport == "raw" or result.transport == "splithttp") then + if result.type == "sing-box" and (result.transport == "mkcp" or result.transport == "xhttp" or result.transport == "splithttp") then log("跳过节点:" .. result.remarks ..",因Sing-Box不支持" .. szType .. "协议的" .. result.transport .. "传输方式,需更换Xray。") return nil end @@ -582,7 +585,7 @@ local function processData(szType, content, add_mode, add_from) if ss_type_default == "xray" and has_xray then result.type = 'Xray' result.protocol = 'shadowsocks' - result.transport = 'tcp' + result.transport = 'raw' end if ss_type_default == "sing-box" and has_singbox then result.type = 'sing-box' @@ -623,6 +626,11 @@ local function processData(szType, content, add_mode, add_from) if params.type then params.type = string.lower(params.type) + if result.type == "sing-box" and params.type == "raw" then + params.type = "tcp" + elseif result.type == "Xray" and params.type == "tcp" then + params.type = "raw" + end result.transport = params.type if result.type ~= "SS-Rust" and result.type ~= "SS" then if params.type == 'ws' then @@ -679,7 +687,7 @@ local function processData(szType, content, add_mode, add_from) if params.type == 'grpc' then if params.path then result.grpc_serviceName = params.path end if params.serviceName then result.grpc_serviceName = params.serviceName end - result.grpc_mode = params.mode + result.grpc_mode = params.mode or "gun" end result.tls = "0" if params.security == "tls" or params.security == "reality" then @@ -767,10 +775,13 @@ local function processData(szType, content, add_mode, add_from) result.tls_allowInsecure = allowInsecure_default and "1" or "0" end - if not params.type then - params.type = "tcp" - end + if not params.type then params.type = "tcp" end params.type = string.lower(params.type) + if result.type == "sing-box" and params.type == "raw" then + params.type = "tcp" + elseif result.type == "Xray" and params.type == "tcp" then + params.type = "raw" + end result.transport = params.type if params.type == 'ws' then result.ws_host = params.host @@ -826,9 +837,9 @@ local function processData(szType, content, add_mode, add_from) if params.type == 'grpc' then if params.path then result.grpc_serviceName = params.path end if params.serviceName then result.grpc_serviceName = params.serviceName end - result.grpc_mode = params.mode + result.grpc_mode = params.mode or "gun" end - if info.net == 'xhttp' or info.net == 'splithttp' then + if params.type == 'xhttp' or params.type == 'splithttp' then result.xhttp_host = params.host result.xhttp_path = params.path end @@ -837,7 +848,7 @@ local function processData(szType, content, add_mode, add_from) result.flow = params.flow or nil - if result.type == "sing-box" and (result.transport == "mkcp" or result.transport == "xhttp" or result.transport == "raw" or result.transport == "splithttp") then + if result.type == "sing-box" and (result.transport == "mkcp" or result.transport == "xhttp" or result.transport == "splithttp") then log("跳过节点:" .. result.remarks ..",因Sing-Box不支持" .. szType .. "协议的" .. result.transport .. "传输方式,需更换Xray。") return nil end @@ -899,10 +910,13 @@ local function processData(szType, content, add_mode, add_from) result.address = host_port end - if not params.type then - params.type = "tcp" - end + if not params.type then params.type = "tcp" end params.type = string.lower(params.type) + if result.type == "sing-box" and params.type == "raw" then + params.type = "tcp" + elseif result.type == "Xray" and params.type == "tcp" then + params.type = "raw" + end result.transport = params.type if params.type == 'ws' then result.ws_host = params.host @@ -957,9 +971,9 @@ local function processData(szType, content, add_mode, add_from) if params.type == 'grpc' then if params.path then result.grpc_serviceName = params.path end if params.serviceName then result.grpc_serviceName = params.serviceName end - result.grpc_mode = params.mode + result.grpc_mode = params.mode or "gun" end - if info.net == 'xhttp' or info.net == 'splithttp' then + if params.type == 'xhttp' or params.type == 'splithttp' then result.xhttp_host = params.host result.xhttp_path = params.path end @@ -985,7 +999,7 @@ local function processData(szType, content, add_mode, add_from) result.port = port result.tls_allowInsecure = allowInsecure_default and "1" or "0" - if result.type == "sing-box" and (result.transport == "mkcp" or result.transport == "xhttp" or result.transport == "raw" or result.transport == "splithttp") then + if result.type == "sing-box" and (result.transport == "mkcp" or result.transport == "xhttp" or result.transport == "splithttp") then log("跳过节点:" .. result.remarks ..",因Sing-Box不支持" .. szType .. "协议的" .. result.transport .. "传输方式,需更换Xray。") return nil end