BurstObservatory: add option to set http method for burst check (#4835)

* feat: add options to set method for burst check.

* chore: gen proto.

* chore: change protoc-gen-go to latest.

* revert

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
Jesus 2025-06-23 05:48:49 +04:00 committed by GitHub
parent fbae89d017
commit 27742da2c6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 49 additions and 7 deletions

View file

@ -2,6 +2,7 @@ package conf
import (
"google.golang.org/protobuf/proto"
"strings"
"github.com/xtls/xray-core/app/observatory/burst"
"github.com/xtls/xray-core/app/router"
@ -51,15 +52,23 @@ type healthCheckSettings struct {
Interval duration.Duration `json:"interval"`
SamplingCount int `json:"sampling"`
Timeout duration.Duration `json:"timeout"`
HttpMethod string `json:"httpMethod"`
}
func (h healthCheckSettings) Build() (proto.Message, error) {
var httpMethod string
if h.HttpMethod == "" {
httpMethod = "HEAD"
} else {
httpMethod = strings.TrimSpace(h.HttpMethod)
}
return &burst.HealthPingConfig{
Destination: h.Destination,
Connectivity: h.Connectivity,
Interval: int64(h.Interval),
Timeout: int64(h.Timeout),
SamplingCount: int32(h.SamplingCount),
HttpMethod: httpMethod,
}, nil
}