mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-29 16:58:34 +00:00
Merge pull request #633 from XTLS/feature/h2-health-check
Add health check for h2 & gRPC
This commit is contained in:
commit
d9d239750b
9 changed files with 191 additions and 87 deletions
|
@ -7,10 +7,25 @@ import (
|
|||
)
|
||||
|
||||
type GRPCConfig struct {
|
||||
ServiceName string `json:"serviceName"`
|
||||
MultiMode bool `json:"multiMode"`
|
||||
ServiceName string `json:"serviceName" `
|
||||
MultiMode bool `json:"multiMode"`
|
||||
IdleTimeout int32 `json:"idle_timeout"`
|
||||
HealthCheckTimeout int32 `json:"health_check_timeout"`
|
||||
PermitWithoutStream bool `json:"permit_without_stream"`
|
||||
}
|
||||
|
||||
func (g GRPCConfig) Build() (proto.Message, error) {
|
||||
return &grpc.Config{ServiceName: g.ServiceName, MultiMode: g.MultiMode}, nil
|
||||
func (g *GRPCConfig) Build() (proto.Message, error) {
|
||||
if g.IdleTimeout <= 0 {
|
||||
g.IdleTimeout = 0
|
||||
}
|
||||
if g.HealthCheckTimeout <= 0 {
|
||||
g.HealthCheckTimeout = 0
|
||||
}
|
||||
return &grpc.Config{
|
||||
ServiceName: g.ServiceName,
|
||||
MultiMode: g.MultiMode,
|
||||
IdleTimeout: g.IdleTimeout,
|
||||
HealthCheckTimeout: g.HealthCheckTimeout,
|
||||
PermitWithoutStream: g.PermitWithoutStream,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -179,14 +179,24 @@ func (c *WebSocketConfig) Build() (proto.Message, error) {
|
|||
}
|
||||
|
||||
type HTTPConfig struct {
|
||||
Host *StringList `json:"host"`
|
||||
Path string `json:"path"`
|
||||
Host *StringList `json:"host"`
|
||||
Path string `json:"path"`
|
||||
ReadIdleTimeout int32 `json:"read_idle_timeout"`
|
||||
HealthCheckTimeout int32 `json:"health_check_timeout"`
|
||||
}
|
||||
|
||||
// Build implements Buildable.
|
||||
func (c *HTTPConfig) Build() (proto.Message, error) {
|
||||
if c.ReadIdleTimeout <= 0 {
|
||||
c.ReadIdleTimeout = 0
|
||||
}
|
||||
if c.HealthCheckTimeout <= 0 {
|
||||
c.HealthCheckTimeout = 0
|
||||
}
|
||||
config := &http.Config{
|
||||
Path: c.Path,
|
||||
Path: c.Path,
|
||||
IdleTimeout: c.ReadIdleTimeout,
|
||||
HealthCheckTimeout: c.HealthCheckTimeout,
|
||||
}
|
||||
if c.Host != nil {
|
||||
config.Host = []string(*c.Host)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue