Browse Source

Merge pull request #1828 from zxlhhyccc/tuic

luci-app-ssr-plus: Update configuration import and subscribe code.
zxl hhyccc 1 week ago
parent
commit
2e07d3bcab

+ 2 - 12
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua

@@ -1181,19 +1181,8 @@ if is_finded("xray") then
 	end
 	o.rmempty = true
 	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw", tls = true})
-	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw", reality = true})
-
-	o = s:option(ListValue, "xhttp_tls_flow", translate("Flow"))
-	for _, v in ipairs(tls_flows) do
-		if v == "none" then
-		   o.default = "none"
-		   o:value("none", translate("none"))
-		else
-		   o:value("xtls-rprx-vision", translate("xtls-rprx-vision"))
-		end
-	end
-	o.rmempty = true
 	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "xhttp", tls = true})
+	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw", reality = true})
 	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "xhttp", reality = true})
 
 	-- [[ uTLS ]]--
@@ -1305,6 +1294,7 @@ o.rmempty = false
 o:depends("tls", true)
 o:depends("type", "hysteria2")
 o:depends("type", "tuic")
+o:depends({type = "v2ray", v2ray_protocol = "vless", reality = true})
 o.description = translate("If true, allowss insecure connection at TLS client, e.g., TLS server uses unverifiable certificates.")
 
 -- [[ Hysteria2 TLS pinSHA256 ]] --

+ 5 - 4
luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm

@@ -736,16 +736,17 @@ function import_ssr_url(btn, urlname, sid) {
 				setElementValue('cbid.shadowsocksr.' + sid + '.' + params.get("security"), true);
 				dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.' + params.get("security"), event);
 
+				if (params.get("allowInsecure") === "1") {
+					setElementValue('cbid.shadowsocksr.' + sid + '.insecure', true); // 设置 insecure 为 true
+					dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.insecure', event); // 触发事件
+				}
+
 				if (params.get("security") === "tls") {
 					if (params.get("ech") && params.get("ech").trim() !== "") {
 						setElementValue('cbid.shadowsocksr.' + sid + '.enable_ech', true); // 设置 enable_ech 为 true
 						dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.enable_ech', event); // 触发事件
 						setElementValue('cbid.shadowsocksr.' + sid + '.ech_config', params.get("ech") || "");
 					}
-					if (params.get("allowInsecure") === "1") {
-						setElementValue('cbid.shadowsocksr.' + sid + '.insecure', true); // 设置 insecure 为 true
-						dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.insecure', event); // 触发事件
-					}
 				}
 				if (params.get("security") === "reality") {
 					setElementValue('cbid.shadowsocksr.' + sid + '.reality_publickey', params.get("pbk") ? decodeURIComponent(params.get("pbk")) : "");

+ 17 - 6
luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua

@@ -276,12 +276,18 @@ local function processData(szType, content)
 		alias = alias .. remarks
 		result.alias = alias
 	elseif szType == "vmess" then
-		-- 去掉前后空白和#注释
+		-- 去掉前后空白和注释
 		local link = trim(content:gsub("#.*$", ""))
 
-		-- 解析正常节点
-		local success, info = pcall(jsonParse, link)
-		if not success or type(info) ~= "table" then
+		-- Base64 解码
+		local decoded = base64Decode(link)
+		if not decoded or decoded == "" then
+			return nil
+		end
+
+		-- 解析 JSON
+		local ok, info = pcall(jsonParse, decoded)
+		if not ok or type(info) ~= "table" then
 			return nil
 		end
 
@@ -318,9 +324,9 @@ local function processData(szType, content)
 			result.xhttp_host = info.host
 			result.xhttp_path = info.path
 			-- 检查 extra 参数是否存在且非空
-			if params.extra and params.extra ~= "" then
+			if info.extra and info.extra ~= "" then
 				result.enable_xhttp_extra = "1"
-				result.xhttp_extra = params.extra
+				result.xhttp_extra = info.extra
 			end
 			-- 尝试解析 JSON 数据
 			local success, Data = pcall(jsonParse, info.extra or "")
@@ -894,6 +900,11 @@ local function processData(szType, content)
 			result.tls_alpn = alpn
 		end
 
+		-- 处理 insecure 参数
+		if params.allowInsecure and params.allowInsecure ~= "" then
+			result.insecure = "1"
+		end
+
 		-- Reality 参数
 		if security == "reality" then
 			result.reality_publickey = params.pbk and UrlDecode(params.pbk) or nil