mirror of https://github.com/kenzok8/small.git
update 2024-12-29 16:15:50
This commit is contained in:
parent
a817223b35
commit
664fdbced8
|
@ -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");
|
||||
|
@ -936,7 +950,7 @@ local api = require "luci.passwall.api"
|
|||
opt.set(dom_prefix + 'port', m.port || "443");
|
||||
opt.set(dom_prefix + 'password', decodeURIComponent(password));
|
||||
|
||||
queryParam.type = queryParam.type.toLowerCase();
|
||||
queryParam.type = queryParam.type ? queryParam.type.toLowerCase() : "tcp";
|
||||
if (queryParam.type === "kcp" || queryParam.type === "mkcp") {
|
||||
queryParam.type = "mkcp";
|
||||
}
|
||||
|
@ -1000,12 +1014,14 @@ local api = require "luci.passwall.api"
|
|||
opt.set(dom_prefix + 'grpc_mode', queryParam.mode || "gun");
|
||||
}
|
||||
|
||||
queryParam.security = queryParam.security || "tls";
|
||||
opt.set(dom_prefix + 'tls', queryParam.security === "tls");
|
||||
if (queryParam.security === "tls") {
|
||||
var tls_serverName = queryParam.peer;
|
||||
if (queryParam.sni) {
|
||||
tls_serverName = queryParam.sni
|
||||
}
|
||||
tls_serverName = tls_serverName || "";
|
||||
opt.set(dom_prefix + 'tls_serverName', tls_serverName);
|
||||
}
|
||||
if (queryParam.allowinsecure === '1') {
|
||||
|
@ -1019,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");
|
||||
}
|
||||
|
@ -1108,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");
|
||||
}
|
||||
|
@ -1264,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");
|
||||
|
@ -1273,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));
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue