luci: improve hy2 port hopping

This commit is contained in:
lwb1978 2025-04-09 10:03:28 +08:00 committed by xiaorouji
parent e1d21555c2
commit fa4439262b
7 changed files with 13 additions and 15 deletions

View File

@ -26,7 +26,8 @@ o = s:option(Value, _n("address"), translate("Address (Support Domain Name)"))
o = s:option(Value, _n("port"), translate("Port"))
o.datatype = "port"
o = s:option(Value, _n("hop"), translate("Additional ports for hysteria hop"))
o = s:option(Value, _n("hop"), translate("Port hopping range"))
o.description = translate("Format as 1000:2000 or 1000-2000 Multiple groups are separated by commas (,).")
o.rewrite_option = o.option
o = s:option(Value, _n("obfs"), translate("Obfs Password"))

View File

@ -404,8 +404,8 @@ if singbox_tags:find("with_quic") then
end
if singbox_tags:find("with_quic") then
o = s:option(Value, _n("hysteria2_ports"), translate("Port hopping range"))
o.description = translate("Format as 1000:2000 Multiple groups are separated by commas (,).")
o = s:option(Value, _n("hysteria2_hop"), translate("Port hopping range"))
o.description = translate("Format as 1000:2000 or 1000-2000 Multiple groups are separated by commas (,).")
o:depends({ [_n("protocol")] = "hysteria2" })
o = s:option(Value, _n("hysteria2_up_mbps"), translate("Max upload Mbps"))

View File

@ -54,7 +54,7 @@ function gen_config(var)
local server = server_host .. ":" .. server_port
if (node.hysteria2_hop) then
server = server .. "," .. node.hysteria2_hop
server = server .. "," .. string.gsub(node.hysteria2_hop, ":", "-")
end
local config = {

View File

@ -350,8 +350,9 @@ function gen_outbound(flag, node, tag, proxy_table)
if node.protocol == "hysteria2" then
local server_ports = {}
if node.hysteria2_ports then
for range in node.hysteria2_ports:gmatch("([^,]+)") do
if node.hysteria2_hop then
node.hysteria2_hop = string.gsub(node.hysteria2_hop, "-", ":")
for range in node.hysteria2_hop:gmatch("([^,]+)") do
if range:match("^%d+:%d+$") then
table.insert(server_ports, range)
end

View File

@ -511,7 +511,7 @@ local hysteria2_type = map:get("@global_subscribe[0]", "hysteria2_type") or "sin
params += opt.query("obfs", dom_prefix + "hysteria2_obfs_type");
params += opt.query("obfs-password", dom_prefix + "hysteria2_obfs_password");
}
params += opt.query("mport", dom_prefix + "hysteria2_ports");
params += opt.query("mport", dom_prefix + "hysteria2_hop");
}
params = params.replace(/^&/, "");
url =
@ -1300,7 +1300,7 @@ local hysteria2_type = map:get("@global_subscribe[0]", "hysteria2_type") or "sin
opt.set(dom_prefix + 'hysteria2_obfs_type', "salamander");
opt.set(dom_prefix + 'hysteria2_obfs_password', queryParam["obfs-password"]);
}
opt.set(dom_prefix + 'hysteria2_ports', queryParam.mport || "");
opt.set(dom_prefix + 'hysteria2_hop', queryParam.mport || "");
} else if (has_hysteria2) {
opt.set('type', "Hysteria2");
dom_prefix = "hysteria2_"

View File

@ -1492,9 +1492,6 @@ msgstr "空闲超时 "
msgid "Hop Interval"
msgstr "端口跳跃时间 "
msgid "Additional ports for hysteria hop"
msgstr "端口跳跃额外端口"
msgid "HeartbeatPeriod(second)"
msgstr "心跳周期(单位:秒)"
@ -1690,5 +1687,5 @@ msgstr "当选择的出站发生变化时中断现有连接。"
msgid "Port hopping range"
msgstr "端口跳跃范围"
msgid "Format as 1000:2000 Multiple groups are separated by commas (,)."
msgstr "格式为1000:2000 多组时用逗号(,)隔开。"
msgid "Format as 1000:2000 or 1000-2000 Multiple groups are separated by commas (,)."
msgstr "格式为1000:2000 或 1000-2000 多组时用逗号(,)隔开。"

View File

@ -1222,6 +1222,7 @@ local function processData(szType, content, add_mode, add_from)
result.tls_allowInsecure = allowInsecure_default and "1" or "0"
end
result.hysteria2_tls_pinSHA256 = params.pinSHA256
result.hysteria2_hop = params.mport
if hysteria2_type_default == "sing-box" and has_singbox then
result.type = 'sing-box'
@ -1230,13 +1231,11 @@ local function processData(szType, content, add_mode, add_from)
result.hysteria2_obfs_type = "salamander"
result.hysteria2_obfs_password = params["obfs-password"]
end
result.hysteria2_ports = params.mport
elseif has_hysteria2 then
result.type = "Hysteria2"
if params["obfs-password"] then
result.hysteria2_obfs = params["obfs-password"]
end
result.hysteria2_hop = params.mport
end
elseif szType == 'tuic' then
local alias = ""