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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user