瀏覽代碼

luci-app-ssr-plus: Merge `xhttp` and `splithttp`.

zxlhhyccc 1 月之前
父節點
當前提交
947c8d90ae

+ 19 - 25
luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua

@@ -714,8 +714,7 @@ o:value("raw", "RAW (TCP)")
 o:value("kcp", "mKCP")
 o:value("ws", "WebSocket")
 o:value("httpupgrade", "HTTPUpgrade")
-o:value("splithttp", "SplitHTTP")
-o:value("xhttp", "XHTTP")
+o:value("xhttp", "XHTTP (SplitHTTP)")
 o:value("h2", "HTTP/2")
 o:value("quic", "QUIC")
 o:value("grpc", "gRPC")
@@ -784,30 +783,9 @@ o = s:option(Value, "httpupgrade_path", translate("Httpupgrade Path"))
 o:depends("transport", "httpupgrade")
 o.rmempty = true
 
--- [[ splithttp部分 ]]--
-
--- splithttp域名
-o = s:option(Value, "splithttp_host", translate("Splithttp Host"))
-o:depends({transport = "splithttp", tls = false})
-o.rmempty = true
-
--- splithttp路径
-o = s:option(Value, "splithttp_path", translate("Splithttp Path"))
-o:depends("transport", "splithttp")
-o.rmempty = true
-
 -- [[ XHTTP部分 ]]--
-o = s:option(ListValue, "xhttp_alpn", translate("XHTTP ALPN"))
-o.default = ""
-o:value("", translate("Default"))
-o:value("h3")
-o:value("h2")
-o:value("h3,h2")
-o:value("http/1.1")
-o:value("h2,http/1.1")
-o:value("h3,h2,http/1.1")
-o:depends("transport", "xhttp")
 
+-- XHTTP 模式
 o = s:option(ListValue, "xhttp_mode", translate("XHTTP Mode"))
 o:depends("transport", "xhttp")
 o.default = "auto"
@@ -816,15 +794,19 @@ o:value("packet-up")
 o:value("stream-up")
 o:value("stream-one")
 
+-- XHTTP 主机
 o = s:option(Value, "xhttp_host", translate("XHTTP Host"))
-o:depends({transport = "xhttp", tls = false})
+o.datatype = "hostname"
+o:depends("transport", "xhttp")
 o.rmempty = true
 
+-- XHTTP 路径
 o = s:option(Value, "xhttp_path", translate("XHTTP Path"))
 o.placeholder = "/"
 o:depends("transport", "xhttp")
 o.rmempty = true
 
+-- XHTTP 附加项
 o = s:option(Flag, "enable_xhttp_extra", translate("XHTTP Extra"))
 o.description = translate("Enable this option to configure XHTTP Extra (JSON format).")
 o.rmempty = true
@@ -868,6 +850,18 @@ o.validate = function(self, value)
     return value
 end
 
+-- XHTTP ALPN
+o = s:option(ListValue, "xhttp_alpn", translate("XHTTP ALPN"))
+o.default = ""
+o:value("", translate("Default"))
+o:value("h3")
+o:value("h2")
+o:value("h3,h2")
+o:value("http/1.1")
+o:value("h2,http/1.1")
+o:value("h3,h2,http/1.1")
+o:depends({transport = "xhttp", tls = true})
+
 -- [[ H2部分 ]]--
 
 -- H2域名

+ 19 - 27
luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm

@@ -353,7 +353,6 @@ function import_ssr_url(btn, urlname, sid) {
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.password')[0].value = decodeURIComponent(url.username);
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls')[0].checked = true;
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls')[0].dispatchEvent(event);
-			document.getElementsByName('cbid.shadowsocksr.' + sid + '.fingerprint')[0].value = params.get("fp") || "";
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls_host')[0].value = params.get("sni");
 			if (params.get("allowInsecure") === "1") {
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.insecure')[0].checked = true; // 设置 insecure 为 true
@@ -367,9 +366,16 @@ function import_ssr_url(btn, urlname, sid) {
 			}
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.transport')[0].value = 
 				params.get("type") == "http" ? "h2" : 
+				(["xhttp", "splithttp"].includes(params.get("type")) ? "xhttp" : 
 				(["tcp", "raw"].includes(params.get("type")) ? "raw" : 
-				(params.get("type") || "raw"));
+				(params.get("type") || "tcp")));
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.transport')[0].dispatchEvent(event);
+			if (params.get("security") === "tls") {
+				if (params.get("type") == "xhttp" || params.get("type") == "splithttp") {
+					document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_alpn')[0].value = params.get("alpn") || "";
+				}
+				document.getElementsByName('cbid.shadowsocksr.' + sid + '.fingerprint')[0].value = params.get("fp") || "";
+			}
 			switch (params.get("type")) {
 			case "ws":
 				if (params.get("security") !== "tls") {
@@ -383,16 +389,9 @@ function import_ssr_url(btn, urlname, sid) {
 				}
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.httpupgrade_path')[0].value = params.get("path") ? decodeURIComponent(params.get("path")) : "/";
 				break;
-			case "splithttp":
-				if (params.get("security") !== "tls") {
-					document.getElementsByName('cbid.shadowsocksr.' + sid + '.splithttp_host')[0].value = params.get("host") ? decodeURIComponent(params.get("host")) : "";
-				}
-				document.getElementsByName('cbid.shadowsocksr.' + sid + '.splithttp_path')[0].value = params.get("path") ? decodeURIComponent(params.get("path")) : "/";
-				break;
 			case "xhttp":
-				if (params.get("security") !== "tls") {
-					document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_host')[0].value = params.get("host") ? decodeURIComponent(params.get("host")) : "";
-				}
+			case "splithttp":
+				document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_host')[0].value = params.get("host") ? decodeURIComponent(params.get("host")) : "";
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_mode')[0].value = params.get("mode") || "auto";
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_path')[0].value = params.get("path") ? decodeURIComponent(params.get("path")) : "/";
 				if (params.get("extra") && params.get("extra").trim() !== "") {
@@ -452,7 +451,8 @@ function import_ssr_url(btn, urlname, sid) {
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.alter_id')[0].value = ssm.aid;
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.vmess_id')[0].value = ssm.id;
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.transport')[0].value = 
-				(ssm.net === "raw" || ssm.net === "tcp") ? "raw" : ssm.net;
+				(ssm.net === "raw" || ssm.net === "tcp") ? "raw" : 
+				(ssm.net === "xhttp" || ssm.net === "splithttp") ? "xhttp" : ssm.net;
 			document.getElementsByName('cbid.shadowsocksr.' + sid + '.transport')[0].dispatchEvent(event);
 			if (ssm.net === "raw" || ssm.net === "tcp") {
 				if (ssm.type && ssm.type != "http") {
@@ -472,12 +472,8 @@ function import_ssr_url(btn, urlname, sid) {
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.httpupgrade_host')[0].value = ssm.host;
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.httpupgrade_path')[0].value = ssm.path;
 			}
-			if (ssm.net == "splithttp") {
-				document.getElementsByName('cbid.shadowsocksr.' + sid + '.splithttp_host')[0].value = ssm.host;
-				document.getElementsByName('cbid.shadowsocksr.' + sid + '.splithttp_path')[0].value = ssm.path;
-			}
-			if (ssm.net == "xhttp") {
-				document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_mode')[0].value = ssm.mode;
+			if (ssm.net == "xhttp" || ssm.net == "splithttp") {
+				document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_mode')[0].value = ssm.mode || "auto";
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_host')[0].value = ssm.host;
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_path')[0].value = ssm.path;
 				if (ssm.extra !== "" && ssm.extra !== undefined) {
@@ -500,10 +496,10 @@ function import_ssr_url(btn, urlname, sid) {
 			if (ssm.tls == "tls") {
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls')[0].checked = true;
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls')[0].dispatchEvent(event);
-				if (ssm.fq !== "" && ssm.fq !== undefined) {
+				if (ssm.fp !== "" && ssm.fp !== undefined) {
 					document.getElementsByName('cbid.shadowsocksr.' + sid + '.fingerprint')[0].value = ssm.fp;
 				}
-				if (ssm.net == "xhttp") {
+				if (ssm.net == "xhttp" || ssm.net == "splithttp") {
 					document.getElementsByName('cbid.shadowsocksr.' + sid + '.xhttp_alpn')[0].value = ssm.alpn;
 				}
 				document.getElementsByName('cbid.shadowsocksr.' + sid + '.tls_host')[0].value = ssm.sni || ssm.host;
@@ -558,8 +554,9 @@ function import_ssr_url(btn, urlname, sid) {
 			setElementValue('cbid.shadowsocksr.' + sid + '.vmess_id', url.username);
 			setElementValue('cbid.shadowsocksr.' + sid + '.transport', 
 				params.get("type") === "http" ? "h2" : 
+				(["xhttp", "splithttp"].includes(params.get("type")) ? "xhttp" :
 				(["tcp", "raw"].includes(params.get("type")) ? "raw" : 
-				(params.get("type") || "tcp"))
+				(params.get("type") || "raw")))
 			);
 			dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.transport', event);
 			setElementValue('cbid.shadowsocksr.' + sid + '.vless_encryption', params.get("encryption") || "none");
@@ -604,13 +601,8 @@ function import_ssr_url(btn, urlname, sid) {
 				}
 				setElementValue('cbid.shadowsocksr.' + sid + '.httpupgrade_path', params.get("path") ? decodeURIComponent(params.get("path")) : "/");
 				break;
-			case "splithttp":
-				if (params.get("security") !== "tls") {
-					setElementValue('cbid.shadowsocksr.' + sid + '.splithttp_host', params.get("host") ? decodeURIComponent(params.get("host")) : "");
-				}
-				setElementValue('cbid.shadowsocksr.' + sid + '.splithttp_path', params.get("path") ? decodeURIComponent(params.get("path")) : "/");
-				break;
 			case "xhttp":
+			case "splithttp":
 				if (params.get("security") !== "tls") {
 					setElementValue('cbid.shadowsocksr.' + sid + '.xhttp_host', params.get("host") ? decodeURIComponent(params.get("host")) : "");
 				}

文件差異過大導致無法顯示
+ 158 - 166
luci-app-ssr-plus/po/templates/ssr-plus.pot


文件差異過大導致無法顯示
+ 158 - 166
luci-app-ssr-plus/po/zh_Hans/ssr-plus.po


+ 1 - 7
luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua

@@ -242,7 +242,6 @@ end
 					minVersion = "1.3"
 				} or nil,
 				realitySettings = (server.reality == '1') and {
-					alpn =  (server.transport == "xhttp" and server.xhttp_alpn ~= "") and server.xhttp_alpn or nil,
 					publicKey = server.reality_publickey,
 					shortId = server.reality_shortid,
 					spiderX = server.reality_spiderx,
@@ -285,12 +284,7 @@ end
 					host = (server.httpupgrade_host or server.tls_host) or nil,
 					path = server.httpupgrade_path or ""
 				} or nil,
-				splithttpSettings = (server.transport == "splithttp") and {
-					-- splithttp
-					host = (server.splithttp_host or server.tls_host) or nil,
-					path = server.splithttp_path or "/"
-				} or nil,
-				xhttpSettings = (server.transport == "xhttp") and {
+				xhttpSettings = (server.transport == "xhttp" or server.transport == "splithttp") and {
 					-- xhttp
 					mode = server.xhttp_mode or "auto",
 					host = (server.xhttp_host or server.tls_host) or nil,

+ 16 - 14
luci-app-ssr-plus/root/usr/share/shadowsocksr/subscribe.lua

@@ -264,6 +264,9 @@ local function processData(szType, content)
 		if info.net == "tcp" then
 			info.net = "raw"
 		end
+		if info.net == "splithttp" then
+			info.net = "xhttp"
+		end
 		result.transport = info.net
 		result.alter_id = info.aid
 		result.vmess_id = info.id
@@ -278,11 +281,7 @@ local function processData(szType, content)
 			result.httpupgrade_host = info.host
 			result.httpupgrade_path = info.path
 		end
-		if info.net == 'splithttp' then
-			result.splithttp_host = info.host
-			result.splithttp_path = info.path
-		end
-		if info.net == 'xhttp' then
+		if info.net == 'xhttp' or info.net == 'splithttp' then
 			result.xhttp_mode = info.mode
 			result.xhttp_host = info.host
 			result.xhttp_path = info.path
@@ -648,20 +647,20 @@ local function processData(szType, content)
 				result.ech_config = params.ech
 			end
 			-- 处理传输协议
-			result.transport = params.type or "tcp" -- 默认传输协议为 tcp
+			result.transport = params.type or "raw" -- 默认传输协议为 raw
 			if result.transport == "tcp" then
 				result.transport = "raw"
 			end
+			if result.transport == "splithttp" then
+				result.transport = "xhttp"
+			end
 			if result.transport == "ws" then
 				result.ws_host = (result.tls ~= "1") and (params.host and UrlDecode(params.host)) or nil
 				result.ws_path = params.path and UrlDecode(params.path) or "/"
 			elseif result.transport == "httpupgrade" then
 				result.httpupgrade_host = (result.tls ~= "1") and (params.host and UrlDecode(params.host)) or nil
 				result.httpupgrade_path = params.path and UrlDecode(params.path) or "/"
-			elseif result.transport == "splithttp" then
-				result.splithttp_host = (result.tls ~= "1") and (params.host and UrlDecode(params.host)) or nil
-				result.splithttp_path = params.path and UrlDecode(params.path) or "/"
-			elseif result.transport == "xhttp" then
+			elseif result.transport == "xhttp" or result.transport == "splithttp" then
 				result.xhttp_host = (result.tls ~= "1") and (params.host and UrlDecode(params.host)) or nil
 				result.xhttp_mode = params.mode or "auto"
 				result.xhttp_path = params.path and UrlDecode(params.path) or "/"
@@ -718,6 +717,12 @@ local function processData(szType, content)
 		result.vmess_id = url.user
 		result.vless_encryption = params.encryption or "none"
 		result.transport = params.type or "tcp"
+		if result.transport == "tcp" then
+			result.transport = "raw"
+		end
+		if result.transport == "splithttp" then
+			result.transport = "xhttp"
+		end
 		result.tls = (params.security == "tls" or params.security == "xtls") and "1" or "0"
 		result.xhttp_alpn = params.alpn or ""
 		result.tls_host = params.sni
@@ -739,10 +744,7 @@ local function processData(szType, content)
 		elseif result.transport == "httpupgrade" then
 			result.httpupgrade_host = (result.tls ~= "1") and (params.host and UrlDecode(params.host)) or nil
 			result.httpupgrade_path = params.path and UrlDecode(params.path) or "/"
-		elseif result.transport == "splithttp" then
-			result.splithttp_host = (result.tls ~= "1") and (params.host and UrlDecode(params.host)) or nil
-			result.splithttp_path = params.path and UrlDecode(params.path) or "/"
-		elseif result.transport == "xhttp" then
+		elseif result.transport == "xhttp" or result.transport == "splithttp" then
 			result.xhttp_host = (result.tls ~= "1") and (params.host and UrlDecode(params.host)) or nil
 			result.xhttp_mode = params.mode or "auto"
 			result.xhttp_path = params.path and UrlDecode(params.path) or "/"

部分文件因文件數量過多而無法顯示