0
mirror of https://github.com/XTLS/Xray-core.git synced 2025-06-12 11:29:36 +03:00

Metrics: Add direct listen (#4409)

This commit is contained in:
风扇滑翔翼
2025-02-18 19:32:48 +08:00
committed by GitHub
parent c5de08bea6
commit 4b01eb4398
4 changed files with 49 additions and 13 deletions

View File

@ -6,15 +6,21 @@ import (
)
type MetricsConfig struct {
Tag string `json:"tag"`
Tag string `json:"tag"`
Listen string `json:"listen"`
}
func (c *MetricsConfig) Build() (*metrics.Config, error) {
if c.Listen == "" && c.Tag == "" {
return nil, errors.New("Metrics must have a tag or listen address.")
}
// If the tag is empty but have "listen" set a default "Metrics" for compatibility.
if c.Tag == "" {
return nil, errors.New("metrics tag can't be empty.")
c.Tag = "Metrics"
}
return &metrics.Config{
Tag: c.Tag,
Tag: c.Tag,
Listen: c.Listen,
}, nil
}