update 2024-12-30 20:38:39

This commit is contained in:
kenzok8 2024-12-30 20:38:39 +08:00
parent 877204f725
commit 981a076945
16 changed files with 99 additions and 82 deletions

View File

@ -18,7 +18,7 @@ local function _n(name)
end end
local ss_method_list = { local ss_method_list = {
"aes-128-gcm", "aes-256-gcm", "chacha20-poly1305", "xchacha20-poly1305", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305" "aes-128-gcm", "aes-256-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "xchacha20-poly1305", "xchacha20-ietf-poly1305", "2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305"
} }
local security_list = { "none", "auto", "aes-128-gcm", "chacha20-poly1305", "zero" } local security_list = { "none", "auto", "aes-128-gcm", "chacha20-poly1305", "zero" }

View File

@ -246,7 +246,9 @@ function gen_outbound(flag, node, tag, proxy_table)
{ {
address = node.address, address = node.address,
port = tonumber(node.port), port = tonumber(node.port),
method = node.method or nil, method = (node.method == "chacha20-ietf-poly1305" and "chacha20-poly1305") or
(node.method == "xchacha20-ietf-poly1305" and "xchacha20-poly1305") or
(node.method ~= "" and node.method) or nil,
ivCheck = (node.protocol == "shadowsocks") and node.iv_check == "1" or nil, ivCheck = (node.protocol == "shadowsocks") and node.iv_check == "1" or nil,
uot = (node.protocol == "shadowsocks") and node.uot == "1" or nil, uot = (node.protocol == "shadowsocks") and node.uot == "1" or nil,
password = node.password or "", password = node.password or "",

View File

@ -766,17 +766,19 @@ local hysteria2_type = uci:get(appname, "@global_subscribe[0]", "hysteria2_type"
dom_prefix = "xray_" dom_prefix = "xray_"
opt.set('type', "Xray"); opt.set('type', "Xray");
opt.set(dom_prefix + 'protocol', "shadowsocks"); opt.set(dom_prefix + 'protocol', "shadowsocks");
method = method.toLowerCase() === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : method;
} else { } else {
if (["2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305"].includes(method)) { if (["2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305"].includes(method)) {
dom_prefix = "ssrust_" dom_prefix = "ssrust_"
opt.set('type', "SS-Rust"); opt.set('type', "SS-Rust");
method = method.toLowerCase() === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : method;
} else { } else {
dom_prefix = "ss_" dom_prefix = "ss_"
opt.set('type', "SS"); opt.set('type', "SS");
} }
} }
if (ss_type !== "xray") {
method = method.toLowerCase() === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : method;
method = method.toLowerCase() === "xchacha20-poly1305" ? "xchacha20-ietf-poly1305" : method;
}
opt.set(dom_prefix + 'address', server); opt.set(dom_prefix + 'address', server);
opt.set(dom_prefix + 'port', port); opt.set(dom_prefix + 'port', port);
opt.set(dom_prefix + 'password', password || ""); opt.set(dom_prefix + 'password', password || "");
@ -903,6 +905,10 @@ local hysteria2_type = uci:get(appname, "@global_subscribe[0]", "hysteria2_type"
dom_prefix = "ss_" dom_prefix = "ss_"
opt.set('type', "SS"); opt.set('type', "SS");
} }
if (ss_type !== "xray") {
method = method.toLowerCase() === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : method;
method = method.toLowerCase() === "xchacha20-poly1305" ? "xchacha20-ietf-poly1305" : method;
}
var sstr = b64decsafe(url0); var sstr = b64decsafe(url0);
var team = sstr.split('@'); var team = sstr.split('@');
var part1 = team[0].split(':'); var part1 = team[0].split(':');

View File

@ -639,12 +639,9 @@ local function processData(szType, content, add_mode, add_from)
result.protocol = 'shadowsocks' result.protocol = 'shadowsocks'
end end
if result.type == "SS-Rust" and method:lower() == "chacha20-poly1305" then if result.type ~= "Xray" then
result.method = "chacha20-ietf-poly1305" result.method = (method:lower() == "chacha20-poly1305" and "chacha20-ietf-poly1305") or
end (method:lower() == "xchacha20-poly1305" and "xchacha20-ietf-poly1305") or method
if result.type == "Xray" and method:lower() == "chacha20-ietf-poly1305" then
result.method = "chacha20-poly1305"
end end
if result.plugin then if result.plugin then

View File

@ -1,7 +1,6 @@
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local appname = api.appname local appname = api.appname
local sys = api.sys local sys = api.sys
local has_chnlist = api.fs.access("/usr/share/passwall2/rules/chnlist")
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m) api.set_apply_on_parse(m)

View File

@ -1,6 +1,5 @@
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local appname = api.appname local appname = api.appname
local uci = api.uci
local sys = api.sys local sys = api.sys
local port_validate = function(self, value, t) local port_validate = function(self, value, t)
@ -163,7 +162,7 @@ end
sources.write = dynamicList_write sources.write = dynamicList_write
---- TCP No Redir Ports ---- TCP No Redir Ports
local TCP_NO_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_no_redir_ports") local TCP_NO_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_no_redir_ports")
o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports")) o = s:option(Value, "tcp_no_redir_ports", translate("TCP No Redir Ports"))
o:value("", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")") o:value("", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")")
o:value("disable", translate("No patterns are used")) o:value("disable", translate("No patterns are used"))
@ -171,7 +170,7 @@ o:value("1:65535", translate("All"))
o.validate = port_validate o.validate = port_validate
---- UDP No Redir Ports ---- UDP No Redir Ports
local UDP_NO_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_no_redir_ports") local UDP_NO_REDIR_PORTS = m:get("@global_forwarding[0]", "udp_no_redir_ports")
o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"), o = s:option(Value, "udp_no_redir_ports", translate("UDP No Redir Ports"),
"<font color='red'>" .. "<font color='red'>" ..
translate("If you don't want to let the device in the list to go proxy, please choose all.") .. translate("If you don't want to let the device in the list to go proxy, please choose all.") ..
@ -189,8 +188,8 @@ if TCP_NO_REDIR_PORTS == "1:65535" and UDP_NO_REDIR_PORTS == "1:65535" then
o:depends({ tcp_no_redir_ports = "", udp_no_redir_ports = "" }) o:depends({ tcp_no_redir_ports = "", udp_no_redir_ports = "" })
end end
local GLOBAL_ENABLED = uci:get(appname, "@global[0]", "enabled") local GLOBAL_ENABLED = m:get("@global[0]", "enabled")
local NODE = uci:get(appname, "@global[0]", "node") local NODE = m:get("@global[0]", "node")
o = s:option(ListValue, "node", "<a style='color: red'>" .. translate("Node") .. "</a>") o = s:option(ListValue, "node", "<a style='color: red'>" .. translate("Node") .. "</a>")
if GLOBAL_ENABLED == "1" and NODE then if GLOBAL_ENABLED == "1" and NODE then
o:value("", translate("Use global config") .. "(" .. api.get_node_name(NODE) .. ")") o:value("", translate("Use global config") .. "(" .. api.get_node_name(NODE) .. ")")
@ -211,7 +210,7 @@ o.value = "1"
o:depends({ __hide = true }) o:depends({ __hide = true })
---- TCP Redir Ports ---- TCP Redir Ports
local TCP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "tcp_redir_ports") local TCP_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_redir_ports")
o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports")) o = s:option(Value, "tcp_redir_ports", translate("TCP Redir Ports"))
o:value("", translate("Use global config") .. "(" .. TCP_REDIR_PORTS .. ")") o:value("", translate("Use global config") .. "(" .. TCP_REDIR_PORTS .. ")")
o:value("1:65535", translate("All")) o:value("1:65535", translate("All"))
@ -221,7 +220,7 @@ o.validate = port_validate
o:depends({ _hide_node_option = "1", ['!reverse'] = true }) o:depends({ _hide_node_option = "1", ['!reverse'] = true })
---- UDP Redir Ports ---- UDP Redir Ports
local UDP_REDIR_PORTS = uci:get(appname, "@global_forwarding[0]", "udp_redir_ports") local UDP_REDIR_PORTS = m:get("@global_forwarding[0]", "udp_redir_ports")
o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports")) o = s:option(Value, "udp_redir_ports", translate("UDP Redir Ports"))
o:value("", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. ")") o:value("", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. ")")
o:value("1:65535", translate("All")) o:value("1:65535", translate("All"))

View File

@ -1,6 +1,5 @@
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local appname = api.appname local appname = api.appname
local uci = api.uci
local datatypes = api.datatypes local datatypes = api.datatypes
local has_singbox = api.finded_com("singbox") local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray") local has_xray = api.finded_com("xray")
@ -33,7 +32,7 @@ for k, v in pairs(nodes_table) do
end end
local socks_list = {} local socks_list = {}
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s.enabled == "1" and s.node then if s.enabled == "1" and s.node then
socks_list[#socks_list + 1] = { socks_list[#socks_list + 1] = {
id = "Socks_" .. s[".name"], id = "Socks_" .. s[".name"],
@ -66,9 +65,8 @@ end
m:append(Template(appname .. "/global/status")) m:append(Template(appname .. "/global/status"))
local global_cfgid = uci:get_all(appname, "@global[0]")[".name"] local global_cfgid = m:get("@global[0]")[".name"]
s = m:section(NamedSection, global_cfgid)
s = m:section(TypedSection, "global")
s.anonymous = true s.anonymous = true
s.addremove = false s.addremove = false
@ -150,7 +148,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
type:depends({ __hide = true }) --不存在的依赖,即始终隐藏 type:depends({ __hide = true }) --不存在的依赖,即始终隐藏
end end
uci:foreach(appname, "shunt_rules", function(e) m.uci:foreach(appname, "shunt_rules", function(e)
local id = e[".name"] local id = e[".name"]
local node_option = vid .. "-" .. id .. "_node" local node_option = vid .. "-" .. id .. "_node"
if id and e.remarks then if id and e.remarks then
@ -400,7 +398,7 @@ o.rmempty = false
o = s2:option(ListValue, "node", translate("Socks Node")) o = s2:option(ListValue, "node", translate("Socks Node"))
local n = 1 local n = 1
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s[".name"] == section then if s[".name"] == section then
return false return false
end end

View File

@ -1,8 +1,7 @@
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local appname = api.appname local appname = api.appname
local sys = api.sys
local net = require "luci.model.network".init()
local datatypes = api.datatypes local datatypes = api.datatypes
local net = require "luci.model.network".init()
local nodes_table = {} local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do for k, e in ipairs(api.get_valid_nodes()) do

View File

@ -1,17 +1,14 @@
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local appname = api.appname local appname = api.appname
local uci = api.uci
local fs = require "nixio.fs"
local types_dir = "/usr/lib/lua/luci/model/cbi/passwall2/client/type/"
if not arg[1] or not uci:get(appname, arg[1]) then
luci.http.redirect(api.url("node_list"))
end
m = Map(appname, translate("Node Config")) m = Map(appname, translate("Node Config"))
m.redirect = api.url() m.redirect = api.url()
api.set_apply_on_parse(m) api.set_apply_on_parse(m)
if not arg[1] or not m:get(arg[1]) then
luci.http.redirect(api.url("node_list"))
end
s = m:section(NamedSection, arg[1], "nodes", "") s = m:section(NamedSection, arg[1], "nodes", "")
s.addremove = false s.addremove = false
s.dynamic = false s.dynamic = false
@ -25,6 +22,9 @@ o = s:option(Value, "remarks", translate("Node Remarks"))
o.default = translate("Remarks") o.default = translate("Remarks")
o.rmempty = false o.rmempty = false
local fs = require "nixio.fs"
local types_dir = "/usr/lib/lua/luci/model/cbi/passwall2/client/type/"
o = s:option(ListValue, "type", translate("Type")) o = s:option(ListValue, "type", translate("Type"))
local type_table = {} local type_table = {}

View File

@ -1,7 +1,7 @@
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local appname = api.appname local appname = api.appname
local sys = api.sys
local datatypes = api.datatypes local datatypes = api.datatypes
local sys = api.sys
m = Map(appname) m = Map(appname)
api.set_apply_on_parse(m) api.set_apply_on_parse(m)

View File

@ -1,7 +1,6 @@
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local appname = api.appname local appname = api.appname
local fs = api.fs local fs = api.fs
local uci = api.uci
local has_singbox = api.finded_com("singbox") local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray") local has_xray = api.finded_com("xray")
local has_fw3 = api.is_finded("fw3") local has_fw3 = api.is_finded("fw3")

View File

@ -1,6 +1,5 @@
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local appname = api.appname local appname = api.appname
local uci = api.uci
local has_singbox = api.finded_com("singbox") local has_singbox = api.finded_com("singbox")
local has_xray = api.finded_com("xray") local has_xray = api.finded_com("xray")
@ -24,7 +23,7 @@ o.rmempty = false
local auto_switch_tip local auto_switch_tip
local current_node = api.get_cache_var("socks_" .. arg[1]) local current_node = api.get_cache_var("socks_" .. arg[1])
if current_node then if current_node then
local n = uci:get_all(appname, current_node) local n = m:get(current_node)
if n then if n then
if tonumber(m:get(arg[1], "enable_autoswitch") or 0) == 1 then if tonumber(m:get(arg[1], "enable_autoswitch") or 0) == 1 then
if n then if n then
@ -45,7 +44,7 @@ o = s:option(Flag, "bind_local", translate("Bind Local"), translate("When select
o.default = "0" o.default = "0"
local n = 1 local n = 1
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s[".name"] == section then if s[".name"] == section then
return false return false
end end

View File

@ -8,7 +8,6 @@ end
local appname = api.appname local appname = api.appname
local jsonc = api.jsonc local jsonc = api.jsonc
local uci = api.uci
local type_name = "Xray" local type_name = "Xray"
@ -86,7 +85,7 @@ for k, e in ipairs(api.get_valid_nodes()) do
end end
local socks_list = {} local socks_list = {}
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s.enabled == "1" and s.node then if s.enabled == "1" and s.node then
socks_list[#socks_list + 1] = { socks_list[#socks_list + 1] = {
id = "Socks_" .. s[".name"], id = "Socks_" .. s[".name"],
@ -184,7 +183,7 @@ if #nodes_table > 0 then
o.default = o.keylist[1] o.default = o.keylist[1]
end end
end end
uci:foreach(appname, "shunt_rules", function(e) m.uci:foreach(appname, "shunt_rules", function(e)
if e[".name"] and e.remarks then if e[".name"] and e.remarks then
o = s:option(ListValue, _n(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks)) o = s:option(ListValue, _n(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks))
o:value("", translate("Close")) o:value("", translate("Close"))
@ -336,8 +335,10 @@ o:depends({ [_n("protocol")] = "shadowsocks" })
o = s:option(Flag, _n("reality"), translate("REALITY")) o = s:option(Flag, _n("reality"), translate("REALITY"))
o.default = 0 o.default = 0
o:depends({ [_n("tls")] = true, [_n("transport")] = "raw" }) o:depends({ [_n("tls")] = true, [_n("transport")] = "raw" })
o:depends({ [_n("tls")] = true, [_n("transport")] = "h2" }) o:depends({ [_n("tls")] = true, [_n("transport")] = "ws" })
o:depends({ [_n("tls")] = true, [_n("transport")] = "quic" })
o:depends({ [_n("tls")] = true, [_n("transport")] = "grpc" }) o:depends({ [_n("tls")] = true, [_n("transport")] = "grpc" })
o:depends({ [_n("tls")] = true, [_n("transport")] = "httpupgrade" })
o:depends({ [_n("tls")] = true, [_n("transport")] = "xhttp" }) o:depends({ [_n("tls")] = true, [_n("transport")] = "xhttp" })
o = s:option(ListValue, _n("alpn"), translate("alpn")) o = s:option(ListValue, _n("alpn"), translate("alpn"))
@ -349,7 +350,7 @@ o:value("h3,h2")
o:value("http/1.1") o:value("http/1.1")
o:value("h2,http/1.1") o:value("h2,http/1.1")
o:value("h3,h2,http/1.1") o:value("h3,h2,http/1.1")
o:depends({ [_n("tls")] = true, [_n("reality")] = false }) o:depends({ [_n("tls")] = true })
-- o = s:option(Value, _n("minversion"), translate("minversion")) -- o = s:option(Value, _n("minversion"), translate("minversion"))
-- o.default = "1.3" -- o.default = "1.3"

View File

@ -11,7 +11,6 @@ end
local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'") local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'")
local appname = api.appname local appname = api.appname
local uci = api.uci
local type_name = "sing-box" local type_name = "sing-box"
@ -83,7 +82,7 @@ for k, e in ipairs(api.get_valid_nodes()) do
end end
local socks_list = {} local socks_list = {}
uci:foreach(appname, "socks", function(s) m.uci:foreach(appname, "socks", function(s)
if s.enabled == "1" and s.node then if s.enabled == "1" and s.node then
socks_list[#socks_list + 1] = { socks_list[#socks_list + 1] = {
id = "Socks_" .. s[".name"], id = "Socks_" .. s[".name"],
@ -112,7 +111,7 @@ if #nodes_table > 0 then
o.default = o.keylist[1] o.default = o.keylist[1]
end end
end end
uci:foreach(appname, "shunt_rules", function(e) m.uci:foreach(appname, "shunt_rules", function(e)
if e[".name"] and e.remarks then if e[".name"] and e.remarks then
o = s:option(ListValue, _n(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks)) o = s:option(ListValue, _n(e[".name"]), string.format('* <a href="%s" target="_blank">%s</a>', api.url("shunt_rules", e[".name"]), e.remarks))
o:value("", translate("Close")) o:value("", translate("Close"))

View File

@ -1,13 +1,24 @@
<%+cbi/valueheader%> <%+cbi/valueheader%>
<% <%
local api = require "luci.passwall2.api" local api = require "luci.passwall2.api"
local map = self.map
local ss_type = map:get("@global_subscribe[0]", "ss_type") or "shadowsocks-libev"
local trojan_type = map:get("@global_subscribe[0]", "trojan_type") or "xray"
local vmess_type = map:get("@global_subscribe[0]", "vmess_type") or "xray"
local vless_type = map:get("@global_subscribe[0]", "vless_type") or "xray"
local hysteria2_type = map:get("@global_subscribe[0]", "hysteria2_type") or "sing-box"
-%> -%>
<script src="<%=resource%>/qrcode.min.js"></script> <script src="<%=resource%>/qrcode.min.js"></script>
<script type="text/javascript">//<![CDATA[ <script type="text/javascript">//<![CDATA[
let has_singbox = "<%=api.finded_com("singbox")%>" let has_singbox = "<%=api.finded_com("singbox")%>"
let has_xray = "<%=api.finded_com("xray")%>" let has_xray = "<%=api.finded_com("xray")%>"
let has_hysteria2 = "<%=api.finded_com("hysteria")%>" 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) { function padright(str, cnt, pad) {
return str + Array(cnt + 1).join(pad); return str + Array(cnt + 1).join(pad);
} }
@ -701,7 +712,7 @@ local api = require "luci.passwall2.api"
} }
if (sipIndex !== -1) { if (sipIndex !== -1) {
// SIP002 // 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 temp = url0.substr(sipIndex + 1).replace('/?', '?').split('?');
var serverInfo = temp[0].split(":"); var serverInfo = temp[0].split(":");
var server = serverInfo[0]; var server = serverInfo[0];
@ -728,18 +739,20 @@ local api = require "luci.passwall2.api"
method = userInfo.substr(0, userInfoSplitIndex); method = userInfo.substr(0, userInfoSplitIndex);
password = userInfo.substr(userInfoSplitIndex + 1); password = userInfo.substr(userInfoSplitIndex + 1);
} }
if (has_singbox) { if (ss_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_" dom_prefix = "singbox_"
opt.set('type', "sing-box"); opt.set('type', "sing-box");
opt.set(dom_prefix + 'protocol', "shadowsocks"); opt.set(dom_prefix + 'protocol', "shadowsocks");
} else if (has_xray) { } else if (ss_type == "xray" && has_xray) {
dom_prefix = "xray_" dom_prefix = "xray_"
opt.set('type', "Xray"); opt.set('type', "Xray");
opt.set(dom_prefix + 'protocol', "shadowsocks"); opt.set(dom_prefix + 'protocol', "shadowsocks");
method = method.toLowerCase() === "chacha20-ietf-poly1305" ? "chacha20-poly1305" : method;
} else { } else {
if (["2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305"].includes(method)) { if (["2022-blake3-aes-128-gcm", "2022-blake3-aes-256-gcm", "2022-blake3-chacha20-poly1305"].includes(method)) {
dom_prefix = "ssrust_" dom_prefix = "ssrust_"
opt.set('type', "SS-Rust"); opt.set('type', "SS-Rust");
method = method.toLowerCase() === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : method;
} else { } else {
dom_prefix = "ss_" dom_prefix = "ss_"
opt.set('type', "SS"); opt.set('type', "SS");
@ -763,25 +776,28 @@ local api = require "luci.passwall2.api"
if (queryParam.security) { if (queryParam.security) {
if (queryParam.security == "tls") { if (queryParam.security == "tls") {
opt.set(dom_prefix + 'tls', true); opt.set(dom_prefix + 'tls', true);
opt.set(dom_prefix + 'reality', false) opt.set(dom_prefix + 'reality', false);
opt.set(dom_prefix + 'flow', queryParam.flow || ''); opt.set(dom_prefix + 'flow', queryParam.flow || '');
opt.set(dom_prefix + 'alpn', queryParam.alpn || ''); opt.set(dom_prefix + 'alpn', queryParam.alpn || 'default');
opt.set(dom_prefix + 'tls_serverName', queryParam.sni || ''); opt.set(dom_prefix + 'tls_serverName', queryParam.sni || '');
opt.set(dom_prefix + 'tls_allowInsecure', true); opt.set(dom_prefix + 'tls_allowInsecure', true);
if (queryParam.allowinsecure === '0') { if (queryParam.allowinsecure === '0') {
opt.set(dom_prefix + 'tls_allowInsecure', false); opt.set(dom_prefix + 'tls_allowInsecure', false);
} }
if (queryParam.fp && queryParam.fp.trim() != "") { if (queryParam.fp && queryParam.fp.trim() != "") {
opt.set(dom_prefix + 'utls', true);
opt.set(dom_prefix + 'fingerprint', queryParam.fp); opt.set(dom_prefix + 'fingerprint', queryParam.fp);
} }
} }
if (queryParam.security == "reality") { if (queryParam.security == "reality") {
opt.set(dom_prefix + 'tls', true); opt.set(dom_prefix + 'tls', true);
opt.set(dom_prefix + 'reality', true) opt.set(dom_prefix + 'reality', true);
opt.set(dom_prefix + 'flow', queryParam.flow || ''); opt.set(dom_prefix + 'flow', queryParam.flow || '');
opt.set(dom_prefix + 'alpn', queryParam.alpn || 'default');
opt.set(dom_prefix + 'tls_serverName', queryParam.sni || ''); opt.set(dom_prefix + 'tls_serverName', queryParam.sni || '');
if (queryParam.fp && queryParam.fp.trim() != "") { if (queryParam.fp && queryParam.fp.trim() != "") {
opt.set(dom_prefix + 'utls', true);
opt.set(dom_prefix + 'fingerprint', queryParam.fp); opt.set(dom_prefix + 'fingerprint', queryParam.fp);
} }
opt.set(dom_prefix + 'reality_publicKey', queryParam.pbk || ''); opt.set(dom_prefix + 'reality_publicKey', queryParam.pbk || '');
@ -860,12 +876,12 @@ local api = require "luci.passwall2.api"
var team = sstr.split('@'); var team = sstr.split('@');
var part1 = team[0].split(':'); var part1 = team[0].split(':');
var part2 = team[1].split(':'); var part2 = team[1].split(':');
if (has_singbox) { if (ss_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_" dom_prefix = "singbox_"
opt.set('type', "sing-box"); opt.set('type', "sing-box");
opt.set(dom_prefix + 'protocol', "shadowsocks"); opt.set(dom_prefix + 'protocol', "shadowsocks");
} else if (has_xray) { } else if (ss_type == "xray" && has_xray) {
dom_prefix = "xray_" dom_prefix = "xray_"
opt.set('type', "Xray"); opt.set('type', "Xray");
opt.set(dom_prefix + 'protocol', "shadowsocks"); opt.set(dom_prefix + 'protocol', "shadowsocks");
@ -887,6 +903,15 @@ local api = require "luci.passwall2.api"
} }
} }
if (ssu[0] === "trojan") { if (ssu[0] === "trojan") {
if (trojan_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_"
opt.set('type', "sing-box");
opt.set(dom_prefix + 'protocol', "trojan");
} else {
dom_prefix = "xray_"
opt.set('type', "Xray");
opt.set(dom_prefix + 'protocol', "trojan");
}
var m = parseNodeUrl(ssrurl); var m = parseNodeUrl(ssrurl);
var password = m.passwd; var password = m.passwd;
if (password === "") { if (password === "") {
@ -904,20 +929,12 @@ local api = require "luci.passwall2.api"
queryParam[decodeURIComponent(params[0]).toLowerCase()] = decodeURIComponent(params[1] || ''); queryParam[decodeURIComponent(params[0]).toLowerCase()] = decodeURIComponent(params[1] || '');
} }
} }
if (has_singbox) {
dom_prefix = "singbox_"
opt.set('type', "sing-box");
} else if (has_xray) {
dom_prefix = "xray_"
opt.set('type', "Xray");
}
opt.set(dom_prefix + 'mux', queryParam.mux === '1'); opt.set(dom_prefix + 'mux', queryParam.mux === '1');
opt.set(dom_prefix + 'protocol', "trojan");
opt.set(dom_prefix + 'address', m.hostname); opt.set(dom_prefix + 'address', m.hostname);
opt.set(dom_prefix + 'port', m.port || "443"); opt.set(dom_prefix + 'port', m.port || "443");
opt.set(dom_prefix + 'password', decodeURIComponent(password)); 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") { if (queryParam.type === "kcp" || queryParam.type === "mkcp") {
queryParam.type = "mkcp"; queryParam.type = "mkcp";
} }
@ -981,12 +998,14 @@ local api = require "luci.passwall2.api"
opt.set(dom_prefix + 'grpc_mode', queryParam.mode || "gun"); opt.set(dom_prefix + 'grpc_mode', queryParam.mode || "gun");
} }
queryParam.security = queryParam.security || "tls";
opt.set(dom_prefix + 'tls', queryParam.security === "tls"); opt.set(dom_prefix + 'tls', queryParam.security === "tls");
if (queryParam.security === "tls") { if (queryParam.security === "tls") {
var tls_serverName = queryParam.peer; var tls_serverName = queryParam.peer;
if (queryParam.sni) { if (queryParam.sni) {
tls_serverName = queryParam.sni tls_serverName = queryParam.sni
} }
tls_serverName = tls_serverName || "";
opt.set(dom_prefix + 'tls_serverName', tls_serverName); opt.set(dom_prefix + 'tls_serverName', tls_serverName);
} }
if (queryParam.allowinsecure === '1') { if (queryParam.allowinsecure === '1') {
@ -999,17 +1018,16 @@ local api = require "luci.passwall2.api"
} }
} }
if (ssu[0] === "vmess") { if (ssu[0] === "vmess") {
var sstr = b64DecodeUnicode(ssu[1]); if (vmess_type == "sing-box" && has_singbox) {
var ploc = sstr.indexOf("/?");
if (has_singbox) {
dom_prefix = "singbox_" dom_prefix = "singbox_"
opt.set('type', "sing-box"); opt.set('type', "sing-box");
} } else {
if (has_xray) {
dom_prefix = "xray_" dom_prefix = "xray_"
opt.set('type', "Xray"); opt.set('type', "Xray");
} }
opt.set(dom_prefix + 'protocol', "vmess"); opt.set(dom_prefix + 'protocol', "vmess");
var sstr = b64DecodeUnicode(ssu[1]);
var ploc = sstr.indexOf("/?");
var url0, param = ""; var url0, param = "";
if (ploc > 0) { if (ploc > 0) {
url0 = sstr.substr(0, ploc); url0 = sstr.substr(0, ploc);
@ -1090,11 +1108,10 @@ local api = require "luci.passwall2.api"
} }
} }
if (ssu[0] === "vless") { if (ssu[0] === "vless") {
if (has_singbox) { if (vless_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_" dom_prefix = "singbox_"
opt.set('type', "sing-box"); opt.set('type', "sing-box");
} } else {
if (has_xray) {
dom_prefix = "xray_" dom_prefix = "xray_"
opt.set('type', "Xray"); opt.set('type', "Xray");
} }
@ -1124,25 +1141,28 @@ local api = require "luci.passwall2.api"
if (queryParam.security) { if (queryParam.security) {
if (queryParam.security == "tls") { if (queryParam.security == "tls") {
opt.set(dom_prefix + 'tls', true); opt.set(dom_prefix + 'tls', true);
opt.set(dom_prefix + 'reality', false) opt.set(dom_prefix + 'reality', false);
opt.set(dom_prefix + 'flow', queryParam.flow || ''); opt.set(dom_prefix + 'flow', queryParam.flow || '');
opt.set(dom_prefix + 'alpn', queryParam.alpn || ''); opt.set(dom_prefix + 'alpn', queryParam.alpn || 'default');
opt.set(dom_prefix + 'tls_serverName', queryParam.sni || ''); opt.set(dom_prefix + 'tls_serverName', queryParam.sni || '');
opt.set(dom_prefix + 'tls_allowInsecure', true); opt.set(dom_prefix + 'tls_allowInsecure', true);
if (queryParam.allowinsecure === '0') { if (queryParam.allowinsecure === '0') {
opt.set(dom_prefix + 'tls_allowInsecure', false); opt.set(dom_prefix + 'tls_allowInsecure', false);
} }
if (queryParam.fp && queryParam.fp.trim() != "") { if (queryParam.fp && queryParam.fp.trim() != "") {
opt.set(dom_prefix + 'utls', true);
opt.set(dom_prefix + 'fingerprint', queryParam.fp); opt.set(dom_prefix + 'fingerprint', queryParam.fp);
} }
} }
if (queryParam.security == "reality") { if (queryParam.security == "reality") {
opt.set(dom_prefix + 'tls', true); opt.set(dom_prefix + 'tls', true);
opt.set(dom_prefix + 'reality', true) opt.set(dom_prefix + 'reality', true);
opt.set(dom_prefix + 'flow', queryParam.flow || ''); opt.set(dom_prefix + 'flow', queryParam.flow || '');
opt.set(dom_prefix + 'alpn', queryParam.alpn || 'default');
opt.set(dom_prefix + 'tls_serverName', queryParam.sni || ''); opt.set(dom_prefix + 'tls_serverName', queryParam.sni || '');
if (queryParam.fp && queryParam.fp.trim() != "") { if (queryParam.fp && queryParam.fp.trim() != "") {
opt.set(dom_prefix + 'utls', true);
opt.set(dom_prefix + 'fingerprint', queryParam.fp); opt.set(dom_prefix + 'fingerprint', queryParam.fp);
} }
opt.set(dom_prefix + 'reality_publicKey', queryParam.pbk || ''); opt.set(dom_prefix + 'reality_publicKey', queryParam.pbk || '');
@ -1243,17 +1263,16 @@ local api = require "luci.passwall2.api"
queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || ''); queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || '');
} }
} }
if (has_singbox) { if (hysteria2_type == "sing-box" && has_singbox) {
dom_prefix = "singbox_"
opt.set('type', "sing-box"); opt.set('type', "sing-box");
dom_prefix = "singbox_"
opt.set(dom_prefix + 'protocol', "hysteria2"); opt.set(dom_prefix + 'protocol', "hysteria2");
opt.set(dom_prefix + 'hysteria2_auth_password', decodeURIComponent(password)); opt.set(dom_prefix + 'hysteria2_auth_password', decodeURIComponent(password));
if (queryParam["obfs-password"]) { if (queryParam["obfs-password"]) {
opt.set(dom_prefix + 'hysteria2_obfs_type', "salamander"); opt.set(dom_prefix + 'hysteria2_obfs_type', "salamander");
opt.set(dom_prefix + 'hysteria2_obfs_password', queryParam["obfs-password"]); opt.set(dom_prefix + 'hysteria2_obfs_password', queryParam["obfs-password"]);
} }
} } else if (has_hysteria2) {
if (has_hysteria2) {
opt.set('type', "Hysteria2"); opt.set('type', "Hysteria2");
dom_prefix = "hysteria2_" dom_prefix = "hysteria2_"
opt.set(dom_prefix + 'auth_password', decodeURIComponent(password)); opt.set(dom_prefix + 'auth_password', decodeURIComponent(password));

View File

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