luci: add Xray VLESS REALITY share link (#2396)

This commit is contained in:
Gzxhwq 2023-03-26 20:37:11 +08:00 committed by sbwml
parent 146648178c
commit 8c3a8663c8
2 changed files with 51 additions and 11 deletions

View File

@ -226,8 +226,10 @@ local has_xray = api.is_finded("xray")
info.path = opt.get("h2_path").value;
} else if (v_transport === "tcp") {
info.type = opt.get("tcp_guise").value;
info.host = opt.get("tcp_guise_http_host").value;
info.path = opt.get("tcp_guise_http_path").value;
if (info.type === "http") {
info.host = opt.get("tcp_guise_http_host").value;
info.path = opt.get("tcp_guise_http_path").value;
}
} else if (v_transport === "mkcp") {
v_transport = "kcp";
info.type = opt.get("mkcp_guise").value;
@ -265,6 +267,7 @@ local has_xray = api.is_finded("xray")
params += opt.query("host", "ws_host");
params += opt.query("path", "ws_path");
} else if (v_transport === "h2") {
v_transport = "http";
params += opt.query("host", "h2_host");
params += opt.query("path", "h2_path");
} else if (v_transport === "tcp") {
@ -282,6 +285,7 @@ local has_xray = api.is_finded("xray")
//不知道是用path还是serviceName这里先这样吧
params += opt.query("path", "grpc_serviceName");
params += opt.query("serviceName", "grpc_serviceName");
params += opt.query("mode", "grpc_mode");
}
params += "&type=" + v_transport;
@ -289,15 +293,25 @@ local has_xray = api.is_finded("xray")
if (opt.get("tls").checked) {
var v_security = "tls";
params += "&security=" + v_security;
if (opt.get("tlsflow").value) {
if (opt.get("xray_fingerprint") && opt.get("xray_fingerprint").value != "") {
let v_fp = opt.get("xray_fingerprint").value;
params += "&fp=" + v_fp;
}
if(opt.get("reality") && opt.get("reality").checked) {
v_security = "reality";
if (opt.get("reality_fingerprint") && opt.get("reality_fingerprint").value != "") {
let v_fp = opt.get("reality_fingerprint").value;
params += "&fp=" + v_fp;
}
params += opt.query("pbk", "reality_publicKey");
params += opt.query("sid", "reality_shortId");
params += opt.query("spx", "reality_spiderX");
}
if (opt.get("tlsflow") && opt.get("tlsflow").value) {
let v_flow = opt.get("tlsflow").value;
params += "&flow=" + v_flow;
}
if (opt.get("xray_fingerprint").value && opt.get("xray_fingerprint").value != "") {
let v_fp = opt.get("xray_fingerprint").value
params += "&fp=" + v_fp;
}
params += "&security=" + v_security;
params += opt.query("sni", "tls_serverName");
}
@ -855,6 +869,7 @@ local has_xray = api.is_finded("xray")
if (queryParam.security) {
if (queryParam.security == "tls") {
opt.set('tls', true);
opt.set('reality', false)
opt.set('tlsflow', queryParam.flow || '');
opt.set('tls_serverName', queryParam.sni || '');
opt.set('tls_allowInsecure', true);
@ -865,11 +880,27 @@ local has_xray = api.is_finded("xray")
opt.set('xray_fingerprint', queryParam.fp);
}
}
if (queryParam.security == "reality") {
opt.set('tls', true);
opt.set('reality', true)
opt.set('tlsflow', queryParam.flow || '');
opt.set('tls_serverName', queryParam.sni || '');
if (queryParam.fp && queryParam.fp.trim() != "") {
opt.set('reality_fingerprint', queryParam.fp);
}
opt.set('reality_publicKey', queryParam.pbk || '');
opt.set('reality_shortId', queryParam.sid || '');
opt.set('reality_spiderX', queryParam.spx || '');
}
}
queryParam.type = queryParam.type.toLowerCase();
if (queryParam.type === "kcp" || queryParam.type === "mkcp")
queryParam.type = "mkcp"
if (queryParam.type === "h2" || queryParam.type === "http")
queryParam.type = "h2"
opt.set('transport', queryParam.type);
if (queryParam.type === "tcp") {
opt.set('tcp_guise', queryParam.headerType || "none");
@ -880,7 +911,7 @@ local has_xray = api.is_finded("xray")
} else if (queryParam.type === "ws") {
opt.set('ws_host', queryParam.host || "");
opt.set('ws_path', queryParam.path || "");
} else if (queryParam.type === "h2") {
} else if (queryParam.type === "h2" || queryParam.type === "http") {
opt.set('h2_host', queryParam.host || "");
opt.set('h2_path', queryParam.path || "");
} else if (queryParam.type === "quic") {
@ -891,6 +922,7 @@ local has_xray = api.is_finded("xray")
opt.set('mkcp_guise', queryParam.headerType || "none");
} else if (queryParam.type === "grpc") {
opt.set('grpc_serviceName', (queryParam.serviceName || queryParam.path) || "");
opt.set('grpc_mode', queryParam.mode);
}
if (m.hash) {

View File

@ -737,7 +737,8 @@ local function processData(szType, content, add_mode, add_from)
result.ws_host = params.host
result.ws_path = params.path
end
if params.type == 'h2' then
if params.type == 'h2' or params.type == 'http' then
params.type = "h2"
result.h2_host = params.host
result.h2_path = params.path
end
@ -765,17 +766,24 @@ local function processData(szType, content, add_mode, add_from)
if params.type == 'grpc' then
if params.path then result.grpc_serviceName = params.path end
if params.serviceName then result.grpc_serviceName = params.serviceName end
result.grpc_mode = params.mode
end
result.transport = params.type
result.encryption = params.encryption or "none"
result.tls = "0"
if params.security == "tls" then
if params.security == "tls" or params.security == "reality" then
result.tls = "1"
result.tlsflow = params.flow or nil
result.tls_serverName = (params.sni and params.sni ~= "") and params.sni or params.host
result.fingerprint = (params.fp and params.fp ~= "") and params.fp or "chrome"
if params.security == "reality" then
result.reality = "1"
result.reality_publicKey = params.pbk or nil
result.reality_shortId = params.sid or nil
result.reality_spiderX = params.spx or nil
end
end
result.port = port