mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-05 21:06:47 +00:00
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package conf
|
|
|
|
import (
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
"github.com/xtls/xray-core/app/observatory"
|
|
"github.com/xtls/xray-core/app/observatory/burst"
|
|
"github.com/xtls/xray-core/infra/conf/cfgcommon/duration"
|
|
)
|
|
|
|
type ObservatoryConfig struct {
|
|
SubjectSelector []string `json:"subjectSelector"`
|
|
ProbeURL string `json:"probeURL"`
|
|
ProbeInterval duration.Duration `json:"probeInterval"`
|
|
EnableConcurrency bool `json:"enableConcurrency"`
|
|
}
|
|
|
|
func (o *ObservatoryConfig) Build() (proto.Message, error) {
|
|
return &observatory.Config{SubjectSelector: o.SubjectSelector, ProbeUrl: o.ProbeURL, ProbeInterval: int64(o.ProbeInterval), EnableConcurrency: o.EnableConcurrency}, nil
|
|
}
|
|
|
|
type BurstObservatoryConfig struct {
|
|
SubjectSelector []string `json:"subjectSelector"`
|
|
// health check settings
|
|
HealthCheck *healthCheckSettings `json:"pingConfig,omitempty"`
|
|
}
|
|
|
|
func (b BurstObservatoryConfig) Build() (proto.Message, error) {
|
|
if result, err := b.HealthCheck.Build(); err == nil {
|
|
return &burst.Config{SubjectSelector: b.SubjectSelector, PingConfig: result.(*burst.HealthPingConfig)}, nil
|
|
} else {
|
|
return nil, err
|
|
}
|
|
}
|