Browse Source

luci-app-ssr-plus: Merge `tcp` `raw` transport protocols, compatible legacy configurations and subscribe.

zxlhhyccc 11 months ago
parent
commit
84dd87687e

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

@@ -618,8 +618,7 @@ o:depends({type = "v2ray", v2ray_protocol = "socks"})
 
 -- 传输协议
 o = s:option(ListValue, "transport", translate("Transport"))
-o:value("tcp", "TCP")
-o:value("raw", "RAW")
+o:value("raw", "RAW (TCP)")
 o:value("kcp", "mKCP")
 o:value("ws", "WebSocket")
 o:value("httpupgrade", "HTTPUpgrade")
@@ -635,17 +634,9 @@ o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
 o:depends({type = "v2ray", v2ray_protocol = "socks"})
 o:depends({type = "v2ray", v2ray_protocol = "http"})
 
--- [[ TCP部分 ]]--
+-- [[ RAW部分 ]]--
 -- TCP伪装
 o = s:option(ListValue, "tcp_guise", translate("Camouflage Type"))
-o:depends("transport", "tcp")
-o:value("none", translate("None"))
-o:value("http", "HTTP")
-o.rmempty = true
-
--- [[ RAW部分 ]]--
--- RAW伪装
-o = s:option(ListValue, "raw_guise", translate("Camouflage Type"))
 o:depends("transport", "raw")
 o:value("none", translate("None"))
 o:value("http", "HTTP")
@@ -654,13 +645,11 @@ o.rmempty = true
 -- HTTP域名
 o = s:option(Value, "http_host", translate("HTTP Host"))
 o:depends("tcp_guise", "http")
-o:depends("raw_guise", "http")
 o.rmempty = true
 
 -- HTTP路径
 o = s:option(Value, "http_path", translate("HTTP Path"))
 o:depends("tcp_guise", "http")
-o:depends("raw_guise", "http")
 o.rmempty = true
 
 -- [[ WS部分 ]]--
@@ -943,9 +932,7 @@ if is_finded("xray") then
 		end
 	end
 	o.rmempty = true
-	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", tls = true})
 	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw", tls = true})
-	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "tcp", reality = true})
 	o:depends({type = "v2ray", v2ray_protocol = "vless", transport = "raw", reality = true})
 
 	-- [[ uTLS ]]--

+ 2 - 9
luci-app-ssr-plus/luasrc/view/shadowsocksr/ssrurl.htm

@@ -333,7 +333,7 @@ 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" : 
-				(params.get("type") === "raw" ? "raw" : 
+				(["tcp", "raw"].includes(params.get("type")) ? "raw" :  
 				(params.get("type") || "tcp"))
 			);
 			dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.transport', event);
@@ -392,6 +392,7 @@ function import_ssr_url(btn, urlname, sid) {
 				setElementValue('cbid.shadowsocksr.' + sid + '.grpc_mode', params.get("mode") || "gun");
 				break;
 			case "tcp":
+			case "raw":
 				setElementValue('cbid.shadowsocksr.' + sid + '.tcp_guise', params.get("headerType") || "none");
 				dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.tcp_guise', event);
 				if (params.get("headerType") === "http") {
@@ -399,14 +400,6 @@ function import_ssr_url(btn, urlname, sid) {
 					setElementValue('cbid.shadowsocksr.' + sid + '.http_path', params.get("path") ? decodeURIComponent(params.get("path")) : "");
 				}
 				break;
-			case "raw":
-				setElementValue('cbid.shadowsocksr.' + sid + '.raw_guise', params.get("headerType") || "none");
-				dispatchEventIfExists('cbid.shadowsocksr.' + sid + '.raw_guise', event);
-				if (params.get("headerType") === "http") {
-					setElementValue('cbid.shadowsocksr.' + sid + '.http_host', params.get("host") ? decodeURIComponent(params.get("host")) : "");
-					setElementValue('cbid.shadowsocksr.' + sid + '.http_path', params.get("path") ? decodeURIComponent(params.get("path")) : "");
-				}
-				break;
 			}
 			s.innerHTML = "<font style=\'color:green\'><%:Import configuration information successfully.%></font>";
 			return false;

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

@@ -220,7 +220,7 @@ end
 					fingerprint = server.fingerprint,
 					serverName = server.tls_host
 				} or nil,
-				tcpSettings = (server.transport == "tcp") and {
+				rawSettings = (server.transport == "raw" or server.transport == "tcp") and {
 					-- tcp
 					header = {
 						type = server.tcp_guise or "none",
@@ -231,17 +231,6 @@ end
 						} or nil
 					}
 				} or nil,
-				rawSettings = (server.transport == "raw") and {
-					-- raw
-					header = {
-						type = server.raw_guise or "none",
-						request = (server.raw_guise == "http") and {
-							-- request
-							path = {server.http_path} or {"/"},
-							headers = {Host = {server.http_host} or {}}
-						} or nil
-					}
-				} or nil,
 				kcpSettings = (server.transport == "kcp") and {
 					-- kcp
 					mtu = tonumber(server.mtu),

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

@@ -400,18 +400,12 @@ local function processData(szType, content)
 		elseif result.transport == "grpc" then
 			result.serviceName = params.serviceName
 			result.grpc_mode = params.mode or "gun"
-		elseif result.transport == "tcp" then
+		elseif result.transport == "tcp" or result.transport == "raw" then
 			result.tcp_guise = params.headerType or "none"
 			if result.tcp_guise == "http" then
 				result.tcp_host = params.host and UrlDecode(params.host) or nil
 				result.tcp_path = params.path and UrlDecode(params.path) or nil
 			end
-		elseif result.transport == "raw" then
-			result.raw_guise = params.headerType or "none"
-			if result.raw_guise == "http" then
-				result.tcp_host = params.host and UrlDecode(params.host) or nil
-				result.tcp_path = params.path and UrlDecode(params.path) or nil
-			end
 		end
 	end
 	if not result.alias then