luci-app-passwall: sync upstream

last commit: 814261eaa7
This commit is contained in:
gitea-action 2024-12-29 16:00:16 +08:00
parent 58275d3fc3
commit c99634af74
2 changed files with 28 additions and 17 deletions

View File

@ -1,12 +1,24 @@
<%+cbi/valueheader%>
<%
local api = require "luci.passwall.api"
local appname = 'passwall'
local uci = api.libuci
local ss_type = uci:get(appname, "@global_subscribe[0]", "ss_type") or "shadowsocks-libev"
local trojan_type = uci:get(appname, "@global_subscribe[0]", "trojan_type") or "trojan-plus"
local vmess_type = uci:get(appname, "@global_subscribe[0]", "vmess_type") or "xray"
local vless_type = uci:get(appname, "@global_subscribe[0]", "vless_type") or "xray"
local hysteria2_type = uci:get(appname, "@global_subscribe[0]", "hysteria2_type") or "hysteria2"
-%>
<script src="<%=resource%>/qrcode.min.js"></script>
<script type="text/javascript">//<![CDATA[
let has_singbox = "<%=api.finded_com("singbox")%>"
let has_xray = "<%=api.finded_com("xray")%>"
let has_hysteria2 = "<%=api.finded_com("hysteria")%>"
let ss_type = "<%=ss_type%>"
let trojan_type = "<%=trojan_type%>"
let vmess_type = "<%=vmess_type%>"
let vless_type = "<%=vless_type%>"
let hysteria2_type = "<%=hysteria2_type%>"
function padright(str, cnt, pad) {
return str + Array(cnt + 1).join(pad);
@ -719,7 +731,7 @@ local api = require "luci.passwall.api"
}
if (sipIndex !== -1) {
// SIP002
var userInfo = b64decsafe(url0.substr(0, sipIndex));
var userInfo = b64decsafe(decodeURIComponent(url0.substr(0, sipIndex)));
var temp = url0.substr(sipIndex + 1).replace('/?', '?').split('?');
var serverInfo = temp[0].split(":");
var server = serverInfo[0];
@ -746,18 +758,20 @@ local api = require "luci.passwall.api"
method = userInfo.substr(0, userInfoSplitIndex);
password = userInfo.substr(userInfoSplitIndex + 1);
}
if (has_singbox) {
if (ss_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_"
opt.set('type', "sing-box");
opt.set(dom_prefix + 'protocol', "shadowsocks");
} else if (has_xray) {
} else if (ss_type == "xray" && has_xray) {
dom_prefix = "xray_"
opt.set('type', "Xray");
opt.set(dom_prefix + 'protocol', "shadowsocks");
method = method.toLowerCase() === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : method;
} else {
if (["2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305"].includes(method)) {
dom_prefix = "ssrust_"
opt.set('type', "SS-Rust");
method = method.toLowerCase() === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : method;
} else {
dom_prefix = "ss_"
opt.set('type', "SS");
@ -874,11 +888,11 @@ local api = require "luci.passwall.api"
}
}
} else {
if (has_singbox) {
if (ss_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_"
opt.set('type', "sing-box");
opt.set(dom_prefix + 'protocol', "shadowsocks");
} else if (has_xray) {
} else if (ss_type == "xray" && has_xray) {
dom_prefix = "xray_"
opt.set('type', "Xray");
opt.set(dom_prefix + 'protocol', "shadowsocks");
@ -903,11 +917,11 @@ local api = require "luci.passwall.api"
}
}
if (ssu[0] === "trojan" || ssu[0] === "trojan-plus") {
if (has_singbox) {
if (trojan_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_"
opt.set('type', "sing-box");
opt.set(dom_prefix + 'protocol', "trojan");
} else if (has_xray) {
} else if (trojan_type == "xray" && has_xray) {
dom_prefix = "xray_"
opt.set('type', "Xray");
opt.set(dom_prefix + 'protocol', "trojan");
@ -1021,11 +1035,10 @@ local api = require "luci.passwall.api"
if (ssu[0] === "vmess") {
var sstr = b64DecodeUnicode(ssu[1]);
var ploc = sstr.indexOf("/?");
if (has_singbox) {
if (vmess_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_"
opt.set('type', "sing-box");
}
if (has_xray) {
} else if (has_xray) {
dom_prefix = "xray_"
opt.set('type', "Xray");
}
@ -1110,11 +1123,10 @@ local api = require "luci.passwall.api"
}
}
if (ssu[0] === "vless") {
if (has_singbox) {
if (vless_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_"
opt.set('type', "sing-box");
}
if (has_xray) {
} else if (has_xray) {
dom_prefix = "xray_"
opt.set('type', "Xray");
}
@ -1266,7 +1278,7 @@ local api = require "luci.passwall.api"
queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || '');
}
}
if (has_singbox) {
if (hysteria2_type == "sing-box" && has_singbox) {
opt.set('type', "sing-box");
dom_prefix = "singbox_"
opt.set(dom_prefix + 'protocol', "hysteria2");
@ -1275,8 +1287,7 @@ local api = require "luci.passwall.api"
opt.set(dom_prefix + 'hysteria2_obfs_type', "salamander");
opt.set(dom_prefix + 'hysteria2_obfs_password', queryParam["obfs-password"]);
}
}
if (has_hysteria2) {
} else if (has_hysteria2) {
opt.set('type', "Hysteria2");
dom_prefix = "hysteria2_"
opt.set(dom_prefix + 'auth_password', decodeURIComponent(password));

View File

@ -593,7 +593,7 @@ local function processData(szType, content, add_mode, add_from)
info = info:sub(1, find_index - 1)
end
local hostInfo = split(base64Decode(info), "@")
local hostInfo = split(base64Decode(UrlDecode(info)), "@")
if hostInfo and #hostInfo > 0 then
local host_port = hostInfo[#hostInfo]
-- [2001:4860:4860::8888]:443