2021-04-08 21:20:30 +00:00
|
|
|
package conf
|
|
|
|
|
|
|
|
import (
|
2024-02-18 03:51:37 +00:00
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
|
2021-04-08 21:20:30 +00:00
|
|
|
"github.com/xtls/xray-core/app/observatory"
|
2024-02-18 03:51:37 +00:00
|
|
|
"github.com/xtls/xray-core/app/observatory/burst"
|
2021-10-26 05:00:31 +00:00
|
|
|
"github.com/xtls/xray-core/infra/conf/cfgcommon/duration"
|
2021-04-08 21:20:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ObservatoryConfig struct {
|
2021-08-26 17:01:10 +00:00
|
|
|
SubjectSelector []string `json:"subjectSelector"`
|
|
|
|
ProbeURL string `json:"probeURL"`
|
|
|
|
ProbeInterval duration.Duration `json:"probeInterval"`
|
|
|
|
EnableConcurrency bool `json:"enableConcurrency"`
|
2021-04-08 21:20:30 +00:00
|
|
|
}
|
|
|
|
|
2021-10-26 05:00:31 +00:00
|
|
|
func (o *ObservatoryConfig) Build() (proto.Message, error) {
|
2021-08-26 17:01:10 +00:00
|
|
|
return &observatory.Config{SubjectSelector: o.SubjectSelector, ProbeUrl: o.ProbeURL, ProbeInterval: int64(o.ProbeInterval), EnableConcurrency: o.EnableConcurrency}, nil
|
2021-04-08 21:20:30 +00:00
|
|
|
}
|
2024-02-18 03:51:37 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|