From c4cbcd6674c5817f14c0b43fba95e00a56b62b16 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 14 Jan 2024 00:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20Sync=202024-01-14=2000:25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- luci-app-passwall2/Makefile | 2 +- .../luasrc/passwall2/util_sing-box.lua | 2 -- .../passwall2/node_list/link_share_man.htm | 21 +++++++++----- .../root/usr/share/passwall2/subscribe.lua | 28 +++++++++++-------- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/luci-app-passwall2/Makefile b/luci-app-passwall2/Makefile index d17231a0..a697e7f1 100644 --- a/luci-app-passwall2/Makefile +++ b/luci-app-passwall2/Makefile @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall2 -PKG_VERSION:=1.23-2 +PKG_VERSION:=1.23-3 PKG_RELEASE:= PKG_CONFIG_DEPENDS:= \ diff --git a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua index 24f562dd..7d504dae 100644 --- a/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua +++ b/luci-app-passwall2/luasrc/passwall2/util_sing-box.lua @@ -286,8 +286,6 @@ function gen_outbound(flag, node, tag, proxy_table) if node.protocol == "hysteria" then protocol_table = { - up = node.hysteria_up_mbps .. " Mbps", - down = node.hysteria_down_mbps .. " Mbps", up_mbps = tonumber(node.hysteria_up_mbps), down_mbps = tonumber(node.hysteria_down_mbps), obfs = node.hysteria_obfs, 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 0d83d8ac..341ec969 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 @@ -880,6 +880,11 @@ local api = require "luci.passwall2.api" if (ssu[0] === "hysteria2" || ssu[0] === "hy2") { var m = parseNodeUrl(ssrurl); + var password = m.passwd; + if (password === "") { + s.innerHTML = "<%:Invalid Share URL Format%>"; + return false; + } var queryParam = {}; if (m.search.length > 1) { var query = m.search.split('?'); @@ -891,21 +896,23 @@ local api = require "luci.passwall2.api" queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || ''); } } - opt.set('type', stype); - if (has_singbox) { opt.set('type', "sing-box"); dom_prefix = "singbox_" opt.set(dom_prefix + 'protocol', "hysteria2"); - opt.set(dom_prefix + 'hysteria2_obfs_type', "salamander"); - opt.set(dom_prefix + 'hysteria2_obfs_password', queryParam["obfs-password"]); - opt.set(dom_prefix + 'hysteria2_auth_password', queryParam.auth); + opt.set(dom_prefix + 'hysteria2_auth_password', decodeURIComponent(password)); + if (queryParam["obfs-password"]) { + opt.set(dom_prefix + 'hysteria2_obfs_type', "salamander"); + opt.set(dom_prefix + 'hysteria2_obfs_password', queryParam["obfs-password"]); + } } if (has_hysteria2) { opt.set('type', "Hysteria2"); dom_prefix = "hysteria2_" - opt.set(dom_prefix + 'obfs', queryParam["obfs-password"]); - opt.set(dom_prefix + 'auth_password', queryParam.auth); + opt.set(dom_prefix + 'auth_password', decodeURIComponent(password)); + if (queryParam["obfs-password"]) { + opt.set(dom_prefix + 'obfs', queryParam["obfs-password"]); + } if (queryParam.pinSHA256) { opt.set(dom_prefix + 'tls_pinSHA256', queryParam.pinSHA256); } diff --git a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua index 1905da9d..a8a052f0 100755 --- a/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua +++ b/luci-app-passwall2/root/usr/share/passwall2/subscribe.lua @@ -772,15 +772,18 @@ local function processData(szType, content, add_mode, add_from) content = content:sub(0, idx_sp - 1) end result.remarks = UrlDecode(alias) - - local dat = split(content, '%?') - local host_port = dat[1] + local Info = content + if content:find("@") then + local contents = split(content, "@") + result.hysteria2_auth_password = UrlDecode(contents[1]) + Info = (contents[2] or ""):gsub("/%?", "?") + end + local query = split(Info, "?") + local host_port = query[1] local params = {} - for _, v in pairs(split(dat[2], '&')) do + for _, v in pairs(split(query[2], '&')) do local t = split(v, '=') - if #t > 0 then - params[t[1]] = t[2] - end + params[string.lower(t[1])] = UrlDecode(t[2]) end -- [2001:4860:4860::8888]:443 -- 8.8.8.8:443 @@ -795,7 +798,6 @@ local function processData(szType, content, add_mode, add_from) else result.address = host_port end - result.hysteria2_auth_password = params.auth result.tls_serverName = params.sni if params.insecure and (params.insecure == "1" or params.insecure == "0") then result.tls_allowInsecure = params.insecure @@ -807,13 +809,17 @@ local function processData(szType, content, add_mode, add_from) if has_hysteria2 then result.type = "Hysteria2" - result.hysteria2_obfs = params["obfs-password"] + if params["obfs-password"] then + result.hysteria2_obfs = params["obfs-password"] + end end if hysteria2_type_default == "sing-box" and has_singbox then result.type = 'sing-box' result.protocol = "hysteria2" - result.hysteria2_obfs_type = "salamander" - result.hysteria2_obfs_password = params["obfs-password"] + if params["obfs-password"] then + result.hysteria2_obfs_type = "salamander" + result.hysteria2_obfs_password = params["obfs-password"] + end end else log('暂时不支持' .. szType .. "类型的节点订阅,跳过此节点。")