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