luci: fix hysteria(2) subscribe

This commit is contained in:
xiaorouji 2024-01-13 15:31:57 +08:00 committed by sbwml
parent b631d149a6
commit 2bc3fe627e
4 changed files with 32 additions and 20 deletions

View File

@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall PKG_NAME:=luci-app-passwall
PKG_VERSION:=4.72-1 PKG_VERSION:=4.72-2
PKG_RELEASE:= PKG_RELEASE:=
PKG_CONFIG_DEPENDS:= \ PKG_CONFIG_DEPENDS:= \

View File

@ -285,8 +285,6 @@ function gen_outbound(flag, node, tag, proxy_table)
if node.protocol == "hysteria" then if node.protocol == "hysteria" then
protocol_table = { protocol_table = {
up = node.hysteria_up_mbps .. " Mbps",
down = node.hysteria_down_mbps .. " Mbps",
up_mbps = tonumber(node.hysteria_up_mbps), up_mbps = tonumber(node.hysteria_up_mbps),
down_mbps = tonumber(node.hysteria_down_mbps), down_mbps = tonumber(node.hysteria_down_mbps),
obfs = node.hysteria_obfs, obfs = node.hysteria_obfs,

View File

@ -1049,6 +1049,11 @@ local api = require "luci.passwall.api"
} }
if (ssu[0] === "hysteria2" || ssu[0] === "hy2") { if (ssu[0] === "hysteria2" || ssu[0] === "hy2") {
var m = parseNodeUrl(ssrurl); var m = parseNodeUrl(ssrurl);
var password = m.passwd;
if (password === "") {
s.innerHTML = "<font color='red'><%:Invalid Share URL Format%></font>";
return false;
}
var queryParam = {}; var queryParam = {};
if (m.search.length > 1) { if (m.search.length > 1) {
var query = m.search.split('?'); var query = m.search.split('?');
@ -1060,20 +1065,23 @@ local api = require "luci.passwall.api"
queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || ''); queryParam[decodeURIComponent(params[0])] = decodeURIComponent(params[1] || '');
} }
} }
if (has_singbox) { if (has_singbox) {
opt.set('type', "sing-box"); opt.set('type', "sing-box");
dom_prefix = "singbox_" dom_prefix = "singbox_"
opt.set(dom_prefix + 'protocol', "hysteria2"); opt.set(dom_prefix + 'protocol', "hysteria2");
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_type', "salamander");
opt.set(dom_prefix + 'hysteria2_obfs_password', queryParam["obfs-password"]); opt.set(dom_prefix + 'hysteria2_obfs_password', queryParam["obfs-password"]);
opt.set(dom_prefix + 'hysteria2_auth_password', queryParam.auth); }
} }
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));
if (queryParam["obfs-password"]) {
opt.set(dom_prefix + 'obfs', queryParam["obfs-password"]); opt.set(dom_prefix + 'obfs', queryParam["obfs-password"]);
opt.set(dom_prefix + 'auth_password', queryParam.auth); }
if (queryParam.pinSHA256) { if (queryParam.pinSHA256) {
opt.set(dom_prefix + 'tls_pinSHA256', queryParam.pinSHA256); opt.set(dom_prefix + 'tls_pinSHA256', queryParam.pinSHA256);
} }

View File

@ -873,15 +873,18 @@ local function processData(szType, content, add_mode, add_from)
content = content:sub(0, idx_sp - 1) content = content:sub(0, idx_sp - 1)
end end
result.remarks = UrlDecode(alias) result.remarks = UrlDecode(alias)
local Info = content
local dat = split(content, '%?') if content:find("@") then
local host_port = dat[1] local contents = split(content, "@")
local params = {} result.hysteria2_auth_password = UrlDecode(contents[1])
for _, v in pairs(split(dat[2], '&')) do Info = (contents[2] or ""):gsub("/%?", "?")
local t = split(v, '=')
if #t > 0 then
params[t[1]] = t[2]
end end
local query = split(Info, "?")
local host_port = query[1]
local params = {}
for _, v in pairs(split(query[2], '&')) do
local t = split(v, '=')
params[string.lower(t[1])] = UrlDecode(t[2])
end end
-- [2001:4860:4860::8888]:443 -- [2001:4860:4860::8888]:443
-- 8.8.8.8:443 -- 8.8.8.8:443
@ -896,7 +899,6 @@ local function processData(szType, content, add_mode, add_from)
else else
result.address = host_port result.address = host_port
end end
result.hysteria2_auth_password = params.auth
result.tls_serverName = params.sni result.tls_serverName = params.sni
if params.insecure and (params.insecure == "1" or params.insecure == "0") then if params.insecure and (params.insecure == "1" or params.insecure == "0") then
result.tls_allowInsecure = params.insecure result.tls_allowInsecure = params.insecure
@ -908,14 +910,18 @@ local function processData(szType, content, add_mode, add_from)
if has_hysteria2 then if has_hysteria2 then
result.type = "Hysteria2" result.type = "Hysteria2"
if params["obfs-password"] then
result.hysteria2_obfs = params["obfs-password"] result.hysteria2_obfs = params["obfs-password"]
end end
end
if hysteria2_type_default == "sing-box" and has_singbox then if hysteria2_type_default == "sing-box" and has_singbox then
result.type = 'sing-box' result.type = 'sing-box'
result.protocol = "hysteria2" result.protocol = "hysteria2"
if params["obfs-password"] then
result.hysteria2_obfs_type = "salamander" result.hysteria2_obfs_type = "salamander"
result.hysteria2_obfs_password = params["obfs-password"] result.hysteria2_obfs_password = params["obfs-password"]
end end
end
else else
log('暂时不支持' .. szType .. "类型的节点订阅,跳过此节点。") log('暂时不支持' .. szType .. "类型的节点订阅,跳过此节点。")
return nil return nil