luci-app-passwall: support aead 2022 ciphers for subscription (#2129)

* add missing seed param from mkcp sub node

* support aead 2022 ciphers for subscription

* support share link and import link for ss-rust
This commit is contained in:
sjtuross 2022-10-12 22:23:36 +08:00 committed by sbwml
parent 93b55e56ca
commit 84b4690831
2 changed files with 57 additions and 6 deletions

View File

@ -149,12 +149,41 @@ local has_xray = api.is_finded("xray")
} }
var v_plugin_opts = opt.get("ss_plugin_opts").value; var v_plugin_opts = opt.get("ss_plugin_opts").value;
if (v_plugin_opts && v_plugin_opts != "") { if (v_plugin_opts && v_plugin_opts != "") {
v_plugin += encodeURI(";" + v_plugin_opts); v_plugin += ";" + v_plugin_opts;
} }
params += "&plugin=" + encodeURI(v_plugin); params += "&plugin=" + encodeURIComponent(v_plugin);
} }
params += "&group=" params += "&group="
params += "#" + encodeURI(v_alias.value); params += "#" + encodeURIComponent(v_alias.value);
if (params[0] == "&") {
params = params.substring(1);
}
url += params;
} else if (v_type === "SS-Rust") {
v_type = "SS"
var v_server = opt.get("address");
var v_port = opt.get("port");
var v_method = opt.get("ss_rust_encrypt_method");
var v_password = opt.get("password");
url = btoa(v_method.value + ":" + v_password.value) + "@" +
v_server.value + ":" +
v_port.value + "/?";
var params = "";
var v_plugin = opt.get("ss_plugin").value;
if (v_plugin && v_plugin != "none") {
if (v_plugin == "simple-obfs" || v_plugin == "obfs-local") {
v_plugin = "obfs-local";
}
var v_plugin_opts = opt.get("ss_plugin_opts").value;
if (v_plugin_opts && v_plugin_opts != "") {
v_plugin += ";" + v_plugin_opts;
}
params += "&plugin=" + encodeURIComponent(v_plugin);
}
params += "&group="
params += "#" + encodeURIComponent(v_alias.value);
if (params[0] == "&") { if (params[0] == "&") {
params = params.substring(1); params = params.substring(1);
} }
@ -552,18 +581,23 @@ local has_xray = api.is_finded("xray")
var pluginIndex = pluginInfo.indexOf(";"); var pluginIndex = pluginInfo.indexOf(";");
var pluginNameInfo = pluginInfo.substr(0, pluginIndex); var pluginNameInfo = pluginInfo.substr(0, pluginIndex);
plugin = pluginNameInfo.substr(pluginNameInfo.indexOf("=") + 1) plugin = pluginNameInfo.substr(pluginNameInfo.indexOf("=") + 1)
pluginOpts = pluginInfo.substr(pluginIndex + 1); pluginOpts = pluginInfo.substr(pluginIndex + 1).split("&")[0];
} }
var userInfoSplitIndex = userInfo.indexOf(":"); var userInfoSplitIndex = userInfo.indexOf(":");
if (userInfoSplitIndex !== -1) { if (userInfoSplitIndex !== -1) {
method = userInfo.substr(0, userInfoSplitIndex); method = userInfo.substr(0, userInfoSplitIndex);
password = userInfo.substr(userInfoSplitIndex + 1); password = userInfo.substr(userInfoSplitIndex + 1);
} }
opt.set('type', "SS"); if (["2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305"].includes(method)) {
opt.set('type', "SS-Rust");
opt.set('ss_rust_encrypt_method', method || "");
} else {
opt.set('type', "SS");
opt.set('ss_encrypt_method', method || "");
}
opt.set('address', server); opt.set('address', server);
opt.set('port', port); opt.set('port', port);
opt.set('password', password || ""); opt.set('password', password || "");
opt.set('ss_encrypt_method', method || "");
opt.set('ss_plugin', plugin || "none"); opt.set('ss_plugin', plugin || "none");
if (plugin && plugin != "none") { if (plugin && plugin != "none") {
opt.set('ss_plugin_opts', pluginOpts || ""); opt.set('ss_plugin_opts', pluginOpts || "");

View File

@ -420,6 +420,7 @@ local function processData(szType, content, add_mode, add_from)
result.mkcp_downlinkCapacity = 20 result.mkcp_downlinkCapacity = 20
result.mkcp_readBufferSize = 2 result.mkcp_readBufferSize = 2
result.mkcp_writeBufferSize = 2 result.mkcp_writeBufferSize = 2
result.mkcp_seed = info.seed
end end
if info.net == 'quic' then if info.net == 'quic' then
result.quic_guise = info.type result.quic_guise = info.type
@ -524,6 +525,21 @@ local function processData(szType, content, add_mode, add_from)
end end
end end
end end
local aead2022 = false
for k, v in ipairs({"2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305"}) do
if method:lower() == v:lower() then
aead2022 = true
end
end
if aead2022 then
if ss_aead_type_default == "xray" and has_xray and not result.plugin then
result.type = 'Xray'
result.protocol = 'shadowsocks'
result.transport = 'tcp'
elseif has_ss_rust then
result.type = 'SS-Rust'
end
end
elseif szType == "trojan" then elseif szType == "trojan" then
local alias = "" local alias = ""
if content:find("#") then if content:find("#") then
@ -739,6 +755,7 @@ local function processData(szType, content, add_mode, add_from)
result.mkcp_downlinkCapacity = 20 result.mkcp_downlinkCapacity = 20
result.mkcp_readBufferSize = 2 result.mkcp_readBufferSize = 2
result.mkcp_writeBufferSize = 2 result.mkcp_writeBufferSize = 2
result.mkcp_seed = params.seed
end end
if params.type == 'quic' then if params.type == 'quic' then
result.quic_guise = params.headerType or "none" result.quic_guise = params.headerType or "none"