Skip to content

Commit

Permalink
luci: add sing-box HTTPUpgrade support (xiaorouji#2886)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gzxhwq authored Dec 3, 2023
1 parent f5ff675 commit 0716c8a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ o = s:option(ListValue, option_name("transport"), translate("Transport"))
o:value("tcp", "TCP")
o:value("http", "HTTP")
o:value("ws", "WebSocket")
o:value("httpupgrade", "HTTPUpgrade")
if singbox_tags:find("with_quic") then
o:value("quic", "QUIC")
end
Expand Down Expand Up @@ -509,6 +510,14 @@ o:depends({ [option_name("ws_enableEarlyData")] = true })
o = s:option(Value, option_name("ws_earlyDataHeaderName"), translate("Early data header name"), translate("Recommended value: Sec-WebSocket-Protocol"))
o:depends({ [option_name("ws_enableEarlyData")] = true })

-- [[ HTTPUpgrade部分 ]]--
o = s:option(Value, option_name("httpupgrade_host"), translate("HTTPUpgrade Host"))
o:depends({ [option_name("transport")] = "httpupgrade" })

o = s:option(Value, option_name("httpupgrade_path"), translate("HTTPUpgrade Path"))
o.placeholder = "/"
o:depends({ [option_name("transport")] = "httpupgrade" })

-- [[ gRPC部分 ]]--
o = s:option(Value, option_name("grpc_serviceName"), "ServiceName")
o:depends({ [option_name("transport")] = "grpc" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ o = s:option(ListValue, option_name("transport"), translate("Transport"))
o:value("tcp", "TCP")
o:value("http", "HTTP")
o:value("ws", "WebSocket")
o:value("httpupgrade", "HTTPUpgrade")
o:value("quic", "QUIC")
o:value("grpc", "gRPC")
o:depends({ [option_name("protocol")] = "shadowsocks" })
Expand All @@ -333,6 +334,14 @@ o:depends({ [option_name("transport")] = "ws" })
o = s:option(Value, option_name("ws_path"), translate("WebSocket Path"))
o:depends({ [option_name("transport")] = "ws" })

-- [[ HTTPUpgrade部分 ]]--

o = s:option(Value, option_name("httpupgrade_host"), translate("HTTPUpgrade Host"))
o:depends({ [option_name("transport")] = "httpupgrade" })

o = s:option(Value, option_name("httpupgrade_path"), translate("HTTPUpgrade Path"))
o:depends({ [option_name("transport")] = "httpupgrade" })

-- [[ gRPC部分 ]]--
o = s:option(Value, option_name("grpc_serviceName"), "ServiceName")
o:depends({ [option_name("transport")] = "grpc" })
Expand Down
16 changes: 16 additions & 0 deletions luci-app-passwall/luasrc/passwall/util_sing-box.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ function gen_outbound(flag, node, tag, proxy_table)
}
end

if node.transport == "httpupgrade" then
v2ray_transport = {
type = "httpupgrade",
host = node.httpupgrade_host,
path = node.httpupgrade_path or "/",
}
end

if node.transport == "quic" then
v2ray_transport = {
type = "quic"
Expand Down Expand Up @@ -421,6 +429,14 @@ function gen_config_server(node)
}
end

if node.transport == "httpupgrade" then
v2ray_transport = {
type = "httpupgrade",
host = node.httpupgrade_host,
path = node.httpupgrade_path or "/",
}
end

if node.transport == "quic" then
v2ray_transport = {
type = "quic"
Expand Down

0 comments on commit 0716c8a

Please sign in to comment.