luci: add Hysteria2 support to sing-box client

This commit is contained in:
xiaorouji 2023-09-06 16:12:34 +08:00 committed by sbwml
parent 74fee990c0
commit 4262fe4238
3 changed files with 41 additions and 0 deletions

View File

@ -75,6 +75,9 @@ o:value("vless", "VLESS")
if singbox_tags:find("with_quic") then if singbox_tags:find("with_quic") then
o:value("tuic", "TUIC") o:value("tuic", "TUIC")
end end
if singbox_tags:find("with_quic") then
o:value("hysteria2", "Hysteria2")
end
o:value("_shunt", translate("Shunt")) o:value("_shunt", translate("Shunt"))
o:value("_iface", translate("Custom Interface") .. " (Only Support Xray)") o:value("_iface", translate("Custom Interface") .. " (Only Support Xray)")
@ -356,6 +359,26 @@ if singbox_tags:find("with_quic") then
o:depends({ [option_name("protocol")] = "tuic" }) o:depends({ [option_name("protocol")] = "tuic" })
end end
if singbox_tags:find("with_quic") then
o = s:option(Value, option_name("hysteria2_up_mbps"), translate("Max upload Mbps"))
o:depends({ [option_name("protocol")] = "hysteria2" })
o = s:option(Value, option_name("hysteria2_down_mbps"), translate("Max download Mbps"))
o:depends({ [option_name("protocol")] = "hysteria2" })
o = s:option(ListValue, option_name("hysteria2_obfs_type"), translate("Obfs Type"))
o:value("", translate("Disable"))
o:value("salamander")
o:depends({ [option_name("protocol")] = "hysteria2" })
o = s:option(Value, option_name("hysteria2_obfs_password"), translate("Obfs Password"))
o:depends({ [option_name("protocol")] = "hysteria2" })
o = s:option(Value, option_name("hysteria2_auth_password"), translate("Auth Password"))
o.password = true
o:depends({ [option_name("protocol")] = "hysteria2"})
end
o = s:option(Flag, option_name("tls"), translate("TLS")) o = s:option(Flag, option_name("tls"), translate("TLS"))
o.default = 0 o.default = 0
o:depends({ [option_name("protocol")] = "vmess" }) o:depends({ [option_name("protocol")] = "vmess" })
@ -390,12 +413,14 @@ o = s:option(Value, option_name("tls_serverName"), translate("Domain"))
o:depends({ [option_name("tls")] = true }) o:depends({ [option_name("tls")] = true })
o:depends({ [option_name("protocol")] = "hysteria"}) o:depends({ [option_name("protocol")] = "hysteria"})
o:depends({ [option_name("protocol")] = "tuic" }) o:depends({ [option_name("protocol")] = "tuic" })
o:depends({ [option_name("protocol")] = "hysteria2" })
o = s:option(Flag, option_name("tls_allowInsecure"), translate("allowInsecure"), translate("Whether unsafe connections are allowed. When checked, Certificate validation will be skipped.")) o = s:option(Flag, option_name("tls_allowInsecure"), translate("allowInsecure"), translate("Whether unsafe connections are allowed. When checked, Certificate validation will be skipped."))
o.default = "0" o.default = "0"
o:depends({ [option_name("tls")] = true }) o:depends({ [option_name("tls")] = true })
o:depends({ [option_name("protocol")] = "hysteria"}) o:depends({ [option_name("protocol")] = "hysteria"})
o:depends({ [option_name("protocol")] = "tuic" }) o:depends({ [option_name("protocol")] = "tuic" })
o:depends({ [option_name("protocol")] = "hysteria2" })
if singbox_tags:find("with_utls") then if singbox_tags:find("with_utls") then
o = s:option(Flag, option_name("utls"), translate("uTLS")) o = s:option(Flag, option_name("utls"), translate("uTLS"))

View File

@ -306,6 +306,19 @@ function gen_outbound(flag, node, tag, proxy_table)
} }
end end
if node.protocol == "hysteria2" then
protocol_table = {
up_mbps = (node.hysteria2_up_mbps and tonumber(node.hysteria2_up_mbps)) and tonumber(node.hysteria2_up_mbps) or nil,
down_mbps = (node.hysteria2_down_mbps and tonumber(node.hysteria2_down_mbps)) and tonumber(node.hysteria2_down_mbps) or nil,
obfs = {
type = node.hysteria2_obfs_type,
password = node.hysteria2_obfs_password
},
password = node.hysteria2_auth_password or nil,
tls = tls,
}
end
if protocol_table then if protocol_table then
for key, value in pairs(protocol_table) do for key, value in pairs(protocol_table) do
result[key] = value result[key] = value

View File

@ -481,6 +481,9 @@ msgstr "传输层插件"
msgid "Shadowsocks secondary encryption" msgid "Shadowsocks secondary encryption"
msgstr "Shadowsocks 二次加密" msgstr "Shadowsocks 二次加密"
msgid "Obfs Type"
msgstr "混淆类型"
msgid "Obfs Password" msgid "Obfs Password"
msgstr "混淆密码" msgstr "混淆密码"