Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add health check for h2 & gRPC #747

Merged
merged 4 commits into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions luci-app-ssr-plus/luasrc/model/cbi/shadowsocksr/client-config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ end
o.rmempty = true
o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})

o = s:option(Flag, "ivCheck", translate("Bloom Filter"))
o:depends({type = "v2ray", v2ray_protocol = "shadowsocks"})
o.default = "1"
o.rmempty = false

-- Shadowsocks Plugin
o = s:option(Value, "plugin", translate("Obfs"))
o:value("none", translate("None"))
Expand Down Expand Up @@ -383,6 +388,37 @@ o = s:option(Value, "serviceName", translate("serviceName"))
o:depends("transport", "grpc")
o.rmempty = true

-- gRPC初始窗口
o = s:option(Value, "initial_windows_size", translate("Initial Windows Size"))
o:depends("transport", "grpc")
o.default = 0
o.rmempty = true

-- H2/gRPC健康检查
o = s:option(Flag, "health_check", translate("H2/gRPC Health Check"))
o:depends("transport", "h2")
o:depends("transport", "grpc")
o.rmempty = true

o = s:option(Value, "read_idle_timeout", translate("H2 Read Idle Timeout"))
o:depends({health_check = true, transport = "h2"})
o.default = 60
o.rmempty = true

o = s:option(Value, "idle_timeout", translate("gRPC Idle Timeout"))
o:depends({health_check = true, transport = "grpc"})
o.default = 60
o.rmempty = true

o = s:option(Value, "health_check_timeout", translate("Health Check Timeout"))
o:depends("health_check", 1)
o.default = 20
o.rmempty = true

o = s:option(Flag, "permit_without_stream", translate("Permit Without Stream"))
o:depends({health_check = true, transport = "grpc"})
o.rmempty = true

-- [[ QUIC部分 ]]--
o = s:option(ListValue, "quic_security", translate("QUIC Security"))
o:depends("transport", "quic")
Expand Down
15 changes: 11 additions & 4 deletions luci-app-ssr-plus/root/usr/share/shadowsocksr/gen_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function trojan_shadowsocks()
port = tonumber(server.server_port),
password = server.password,
method = (server.v2ray_protocol == "shadowsocks") and server.encrypt_method_v2ray_ss or nil,
flow = (server.v2ray_protocol == "trojan") and (server.xtls == '1') and (server.vless_flow and server.vless_flow or "xtls-rprx-splice") or nil
flow = (server.v2ray_protocol == "trojan") and (server.xtls == '1') and (server.vless_flow and server.vless_flow or "xtls-rprx-splice") or nil,
ivCheck = (server.v2ray_protocol == "shadowsocks") and (server.ivCheck == '1') or nil
}
}
}
Expand Down Expand Up @@ -117,7 +118,7 @@ local Xray = {
-- 底层传输配置
streamSettings = {
network = server.transport or "tcp",
security = (server.xtls == '1') and "xtls" or (server.tls == '1'or server.transport == "grpc") and "tls" or nil,
security = (server.xtls == '1') and "xtls" or (server.tls == '1') and "tls" or nil,
tlsSettings = (server.tls == '1' and (server.insecure == "1" or server.tls_host or server.fingerprint)) and {
-- tls
fingerprint = server.fingerprint,
Expand Down Expand Up @@ -162,7 +163,9 @@ local Xray = {
httpSettings = (server.transport == "h2") and {
-- h2
path = server.h2_path or "",
host = {server.h2_host} or nil
host = {server.h2_host} or nil,
read_idle_timeout = tonumber(server.read_idle_timeout) or nil,
health_check_timeout = tonumber(server.health_check_timeout) or nil
} or nil,
quicSettings = (server.transport == "quic") and {
-- quic
Expand All @@ -173,7 +176,11 @@ local Xray = {
grpcSettings = (server.transport == "grpc") and {
-- grpc
serviceName = server.serviceName or "",
multiMode = (server.mux == "1") and true or false
multiMode = (server.mux == "1") and true or false,
idle_timeout = tonumber(server.idle_timeout) or nil,
health_check_timeout = tonumber(server.health_check_timeout) or nil,
permit_without_stream = (server.permit_without_stream == "1") and true or nil,
initial_windows_size = tonumber(server.initial_windows_size) or nil
} or nil
},
mux = (server.mux == "1" and server.xtls ~= "1" and server.transport ~= "grpc") and {
Expand Down