Pārlūkot izejas kodu

luci-app-ssr-plus: optimize xray kcp finalmask/udp logic

zxlhhyccc 17 stundas atpakaļ
vecāks
revīzija
b96a3fe3bc

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

@@ -1034,17 +1034,17 @@ o:value("wireguard", translate("WireGuard"))
 o = s:option(ListValue, "kcp_guise", translate("Camouflage Type"))
 o:depends("transport", "kcp")
 o:value("none", translate("None"))
-o:value("header-srtp", translate("VideoCall (SRTP)"))
-o:value("header-utp", translate("BitTorrent (uTP)"))
-o:value("header-wechat", translate("WechatVideo"))
-o:value("header-dtls", translate("DTLS 1.2"))
-o:value("header-wireguard", translate("WireGuard"))
-o:value("header-dns", translate("DNS"))
+o:value("srtp", translate("VideoCall (SRTP)"))
+o:value("utp", translate("BitTorrent (uTP)"))
+o:value("wechat-video", translate("WechatVideo"))
+o:value("dtls", translate("DTLS 1.2"))
+o:value("wireguard", translate("WireGuard"))
+o:value("dns", translate("DNS"))
 o.rmempty = true
 
 o = s:option(Value, "kcp_domain", translate("Camouflage Domain"))
 o.description = translate("Use it together with the DNS disguised type. You can fill in any domain.")
-o:depends("kcp_guise", "header-dns")
+o:depends("kcp_guise", "dns")
 
 o = s:option(Value, "mtu", translate("MTU"))
 o.datatype = "uinteger"

+ 4 - 2
luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua

@@ -412,9 +412,11 @@ end
 				finalmask = (server.transport == "kcp") and {
 					udp = (function()
 						local t = {}
+						local map = {none = "none", srtp = "header-srtp", utp = "header-utp", ["wechat-video"] = "header-wechat",
+							dtls = "header-dtls", wireguard = "header-wireguard", dns = "header-dns"}
 						if server.kcp_guise and server.kcp_guise ~= "none" then
-							local g = { type = server.kcp_guise }
-							if server.kcp_guise == "header-dns" and server.kcp_domain and server.kcp_domain ~= "" then
+							local g = { type = map[server.kcp_guise] }
+							if server.kcp_guise == "dns" and server.kcp_domain and server.kcp_domain ~= "" then
 								g.settings = { domain = server.kcp_domain }
 							end
 							t[#t + 1] = g

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

@@ -396,7 +396,7 @@ local function processData(szType, content)
 		end
 		if info.net == 'kcp' then
 			result.kcp_guise = info.type or "none"
-			if info.type and info.type == "header-dns" then
+			if info.type and info.type == "dns" then
 				result.kcp_guise = info.host or ""
 			end
 			result.mtu = 1350
@@ -719,7 +719,7 @@ local function processData(szType, content)
 				result.h2_path = params.path and UrlDecode(params.path) or nil
 			elseif result.transport == "kcp" then
 				result.kcp_guise = params.headerType or "none"
-				if params.headerType and params.headerType == "header-dns" then
+				if params.headerType and params.headerType == "dns" then
 					result.kcp_domain = params.host or ""
 				end
 				result.seed = params.seed
@@ -914,7 +914,7 @@ local function processData(szType, content)
 					result.h2_path = params.path and UrlDecode(params.path) or nil
 				elseif result.transport == "kcp" then
 					result.kcp_guise = params.headerType or "none"
-					if params.headerType and params.headerType == "header-dns" then
+					if params.headerType and params.headerType == "dns" then
 						result.kcp_domain = params.host or ""
 					end
 					result.seed = params.seed
@@ -1054,7 +1054,7 @@ local function processData(szType, content)
 
 		elseif result.transport == "kcp" then
 			result.kcp_guise = params.headerType or "none"
-			if params.headerType and params.headerType == "header-dns" then
+			if params.headerType and params.headerType == "dns" then
 				result.kcp_domain = params.host or ""
 			end
 			result.seed = params.seed