ソースを参照

Merge pull request #195 from xsm1997/master

luci-app-ssr-plus: add VLESS XTLS support.
coolsnowwolf 5 年 前
コミット
23669362dd

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

@@ -398,6 +398,12 @@ o = s:option(Value, "tls_host", translate("TLS Host"))
 o:depends("tls", "1")
 o.rmempty = true
 
+-- XTLS
+o = s:option(Flag, "xtls", translate("XTLS"))
+o.rmempty = true
+o.default = "0"
+o:depends({type="vless", tls="1"})
+
 -- [[ Mux ]]--
 o = s:option(Flag, "mux", translate("Mux"))
 o.rmempty = true

+ 14 - 2
luci-app-ssr-plus/root/usr/share/shadowsocksr/genvlessconfig.lua

@@ -5,6 +5,16 @@ local proto = arg[2]
 local local_port = arg[3] or "0"
 local socks_port = arg[4] or "0"
 local server = ucursor:get_all("shadowsocksr", server_section)
+local outbound_security = "none"
+
+if (server.xtls == '1')
+then
+	outbound_security = "xtls"
+elseif (server.tls == '1')
+then
+	outbound_security = "tls"
+end
+
 local vless = {
 log = {
 -- error = "/var/ssrplus.log",
@@ -45,6 +55,7 @@ outbound = {
 				users = {
 					{
 						id = server.vmess_id,
+						flow = (server.xtls == '1') and "xtls-rprx-origin" or nil,
 						encryption = server.vless_encryption
 					}
 				}
@@ -54,8 +65,9 @@ outbound = {
 	-- 底层传输配置
 	streamSettings = {
 		network = server.transport,
-		security = (server.tls == '1') and "tls" or "none",
-		tlsSettings = {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,},
+		security = outbound_security,
+		tlsSettings = (outbound_security == "tls") and {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,} or nil,
+		xtlsSettings = (outbound_security == "xtls") and {allowInsecure = (server.insecure ~= "0") and true or false,serverName=server.tls_host,} or nil,
 		tcpSettings = (server.transport == "tcp") and {
 			header = {
 				type = server.tcp_guise,