From 981a0769452d3f8441d6f1246c659099fba26e81 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Mon, 30 Dec 2024 20:38:39 +0800 Subject: [PATCH] update 2024-12-30 20:38:39 --- .../model/cbi/passwall/client/type/ray.lua | 2 +- .../luasrc/passwall/util_xray.lua | 4 +- .../passwall/node_list/link_share_man.htm | 10 ++- .../root/usr/share/passwall/subscribe.lua | 9 +- .../luasrc/model/cbi/passwall2/client/acl.lua | 1 - .../model/cbi/passwall2/client/acl_config.lua | 13 ++- .../model/cbi/passwall2/client/global.lua | 12 ++- .../model/cbi/passwall2/client/haproxy.lua | 3 +- .../cbi/passwall2/client/node_config.lua | 14 +-- .../model/cbi/passwall2/client/node_list.lua | 2 +- .../model/cbi/passwall2/client/other.lua | 1 - .../cbi/passwall2/client/socks_config.lua | 5 +- .../model/cbi/passwall2/client/type/ray.lua | 11 +-- .../cbi/passwall2/client/type/sing-box.lua | 5 +- .../passwall2/node_list/link_share_man.htm | 87 +++++++++++-------- .../root/usr/share/passwall2/subscribe.lua | 2 +- 16 files changed, 99 insertions(+), 82 deletions(-) diff --git a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua index 7718e3edd..7cb119bb9 100644 --- a/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua +++ b/luci-app-passwall/luasrc/model/cbi/passwall/client/type/ray.lua @@ -18,7 +18,7 @@ local function _n(name) end 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" } diff --git a/luci-app-passwall/luasrc/passwall/util_xray.lua b/luci-app-passwall/luasrc/passwall/util_xray.lua index d26ac1b12..bd8ff36c4 100644 --- a/luci-app-passwall/luasrc/passwall/util_xray.lua +++ b/luci-app-passwall/luasrc/passwall/util_xray.lua @@ -246,7 +246,9 @@ function gen_outbound(flag, node, tag, proxy_table) { address = node.address, 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, uot = (node.protocol == "shadowsocks") and node.uot == "1" or nil, password = node.password or "", diff --git a/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm b/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm index 250836ca8..5177cf8f7 100644 --- a/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm +++ b/luci-app-passwall/luasrc/view/passwall/node_list/link_share_man.htm @@ -766,17 +766,19 @@ local hysteria2_type = uci:get(appname, "@global_subscribe[0]", "hysteria2_type" 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"); } } + 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 + 'port', port); opt.set(dom_prefix + 'password', password || ""); @@ -903,6 +905,10 @@ local hysteria2_type = uci:get(appname, "@global_subscribe[0]", "hysteria2_type" dom_prefix = "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 team = sstr.split('@'); var part1 = team[0].split(':'); diff --git a/luci-app-passwall/root/usr/share/passwall/subscribe.lua b/luci-app-passwall/root/usr/share/passwall/subscribe.lua index 305887710..a0232d607 100755 --- a/luci-app-passwall/root/usr/share/passwall/subscribe.lua +++ b/luci-app-passwall/root/usr/share/passwall/subscribe.lua @@ -639,12 +639,9 @@ local function processData(szType, content, add_mode, add_from) result.protocol = 'shadowsocks' end - if result.type == "SS-Rust" and method:lower() == "chacha20-poly1305" then - result.method = "chacha20-ietf-poly1305" - end - - if result.type == "Xray" and method:lower() == "chacha20-ietf-poly1305" then - result.method = "chacha20-poly1305" + if result.type ~= "Xray" then + result.method = (method:lower() == "chacha20-poly1305" and "chacha20-ietf-poly1305") or + (method:lower() == "xchacha20-poly1305" and "xchacha20-ietf-poly1305") or method end if result.plugin then diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl.lua index 1eb1ac542..3df0c9f75 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl.lua @@ -1,7 +1,6 @@ local api = require "luci.passwall2.api" local appname = api.appname local sys = api.sys -local has_chnlist = api.fs.access("/usr/share/passwall2/rules/chnlist") m = Map(appname) api.set_apply_on_parse(m) diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua index 1cf892a5d..e1126e5a0 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/acl_config.lua @@ -1,6 +1,5 @@ local api = require "luci.passwall2.api" local appname = api.appname -local uci = api.uci local sys = api.sys local port_validate = function(self, value, t) @@ -163,7 +162,7 @@ end sources.write = dynamicList_write ---- 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:value("", translate("Use global config") .. "(" .. TCP_NO_REDIR_PORTS .. ")") o:value("disable", translate("No patterns are used")) @@ -171,7 +170,7 @@ o:value("1:65535", translate("All")) o.validate = port_validate ---- 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"), "" .. 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 = "" }) end -local GLOBAL_ENABLED = uci:get(appname, "@global[0]", "enabled") -local NODE = uci:get(appname, "@global[0]", "node") +local GLOBAL_ENABLED = m:get("@global[0]", "enabled") +local NODE = m:get("@global[0]", "node") o = s:option(ListValue, "node", "" .. translate("Node") .. "") if GLOBAL_ENABLED == "1" and NODE then o:value("", translate("Use global config") .. "(" .. api.get_node_name(NODE) .. ")") @@ -211,7 +210,7 @@ o.value = "1" o:depends({ __hide = true }) ---- 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:value("", translate("Use global config") .. "(" .. TCP_REDIR_PORTS .. ")") o:value("1:65535", translate("All")) @@ -221,7 +220,7 @@ o.validate = port_validate o:depends({ _hide_node_option = "1", ['!reverse'] = true }) ---- 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:value("", translate("Use global config") .. "(" .. UDP_REDIR_PORTS .. ")") o:value("1:65535", translate("All")) diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua index 6db24429a..1ca0cd153 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/global.lua @@ -1,6 +1,5 @@ local api = require "luci.passwall2.api" local appname = api.appname -local uci = api.uci local datatypes = api.datatypes local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") @@ -33,7 +32,7 @@ for k, v in pairs(nodes_table) do end local socks_list = {} -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s.enabled == "1" and s.node then socks_list[#socks_list + 1] = { id = "Socks_" .. s[".name"], @@ -66,9 +65,8 @@ end m:append(Template(appname .. "/global/status")) -local global_cfgid = uci:get_all(appname, "@global[0]")[".name"] - -s = m:section(TypedSection, "global") +local global_cfgid = m:get("@global[0]")[".name"] +s = m:section(NamedSection, global_cfgid) s.anonymous = true s.addremove = false @@ -150,7 +148,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then type:depends({ __hide = true }) --不存在的依赖,即始终隐藏 end - uci:foreach(appname, "shunt_rules", function(e) + m.uci:foreach(appname, "shunt_rules", function(e) local id = e[".name"] local node_option = vid .. "-" .. id .. "_node" if id and e.remarks then @@ -400,7 +398,7 @@ o.rmempty = false o = s2:option(ListValue, "node", translate("Socks Node")) local n = 1 -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s[".name"] == section then return false end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/haproxy.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/haproxy.lua index 1fc9806c3..b0c8b04ee 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/haproxy.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/haproxy.lua @@ -1,8 +1,7 @@ local api = require "luci.passwall2.api" local appname = api.appname -local sys = api.sys -local net = require "luci.model.network".init() local datatypes = api.datatypes +local net = require "luci.model.network".init() local nodes_table = {} for k, e in ipairs(api.get_valid_nodes()) do diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_config.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_config.lua index 611765bc5..0486f526b 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_config.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_config.lua @@ -1,17 +1,14 @@ local api = require "luci.passwall2.api" 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.redirect = api.url() 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.addremove = false s.dynamic = false @@ -25,6 +22,9 @@ o = s:option(Value, "remarks", translate("Node Remarks")) o.default = translate("Remarks") 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")) local type_table = {} diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua index 90ffb47bb..75bac734a 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/node_list.lua @@ -1,7 +1,7 @@ local api = require "luci.passwall2.api" local appname = api.appname -local sys = api.sys local datatypes = api.datatypes +local sys = api.sys m = Map(appname) api.set_apply_on_parse(m) diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua index 7bbe82378..2f66f7616 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/other.lua @@ -1,7 +1,6 @@ local api = require "luci.passwall2.api" local appname = api.appname local fs = api.fs -local uci = api.uci local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") local has_fw3 = api.is_finded("fw3") diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/socks_config.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/socks_config.lua index d47cea1e8..e5bc0ca9d 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/socks_config.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/socks_config.lua @@ -1,6 +1,5 @@ local api = require "luci.passwall2.api" local appname = api.appname -local uci = api.uci local has_singbox = api.finded_com("singbox") local has_xray = api.finded_com("xray") @@ -24,7 +23,7 @@ o.rmempty = false local auto_switch_tip local current_node = api.get_cache_var("socks_" .. arg[1]) if current_node then - local n = uci:get_all(appname, current_node) + local n = m:get(current_node) if n then if tonumber(m:get(arg[1], "enable_autoswitch") or 0) == 1 then if n then @@ -45,7 +44,7 @@ o = s:option(Flag, "bind_local", translate("Bind Local"), translate("When select o.default = "0" local n = 1 -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s[".name"] == section then return false end diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/ray.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/ray.lua index b2e2b61a7..a81b48c14 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/ray.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/ray.lua @@ -8,7 +8,6 @@ end local appname = api.appname local jsonc = api.jsonc -local uci = api.uci local type_name = "Xray" @@ -86,7 +85,7 @@ for k, e in ipairs(api.get_valid_nodes()) do end local socks_list = {} -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s.enabled == "1" and s.node then socks_list[#socks_list + 1] = { id = "Socks_" .. s[".name"], @@ -184,7 +183,7 @@ if #nodes_table > 0 then o.default = o.keylist[1] end end -uci:foreach(appname, "shunt_rules", function(e) +m.uci:foreach(appname, "shunt_rules", function(e) if e[".name"] and e.remarks then o = s:option(ListValue, _n(e[".name"]), string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) o:value("", translate("Close")) @@ -336,8 +335,10 @@ o:depends({ [_n("protocol")] = "shadowsocks" }) o = s:option(Flag, _n("reality"), translate("REALITY")) o.default = 0 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")] = "httpupgrade" }) o:depends({ [_n("tls")] = true, [_n("transport")] = "xhttp" }) o = s:option(ListValue, _n("alpn"), translate("alpn")) @@ -349,7 +350,7 @@ o:value("h3,h2") o:value("http/1.1") o:value("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.default = "1.3" diff --git a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua index f3f3232b7..db866d78a 100644 --- a/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua +++ b/luci-app-passwall2/luasrc/model/cbi/passwall2/client/type/sing-box.lua @@ -11,7 +11,6 @@ end local singbox_tags = luci.sys.exec(singbox_bin .. " version | grep 'Tags:' | awk '{print $2}'") local appname = api.appname -local uci = api.uci local type_name = "sing-box" @@ -83,7 +82,7 @@ for k, e in ipairs(api.get_valid_nodes()) do end local socks_list = {} -uci:foreach(appname, "socks", function(s) +m.uci:foreach(appname, "socks", function(s) if s.enabled == "1" and s.node then socks_list[#socks_list + 1] = { id = "Socks_" .. s[".name"], @@ -112,7 +111,7 @@ if #nodes_table > 0 then o.default = o.keylist[1] end end -uci:foreach(appname, "shunt_rules", function(e) +m.uci:foreach(appname, "shunt_rules", function(e) if e[".name"] and e.remarks then o = s:option(ListValue, _n(e[".name"]), string.format('* %s', api.url("shunt_rules", e[".name"]), e.remarks)) o:value("", translate("Close")) diff --git a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm index 1f72fa3b6..227824ca5 100644 --- a/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/node_list/link_share_man.htm @@ -1,13 +1,24 @@ <%+cbi/valueheader%> <% 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" -%>