mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
41
infra/conf/api.go
Normal file
41
infra/conf/api.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package conf
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/xtls/xray-core/v1/app/commander"
|
||||
loggerservice "github.com/xtls/xray-core/v1/app/log/command"
|
||||
handlerservice "github.com/xtls/xray-core/v1/app/proxyman/command"
|
||||
statsservice "github.com/xtls/xray-core/v1/app/stats/command"
|
||||
"github.com/xtls/xray-core/v1/common/serial"
|
||||
)
|
||||
|
||||
type APIConfig struct {
|
||||
Tag string `json:"tag"`
|
||||
Services []string `json:"services"`
|
||||
}
|
||||
|
||||
func (c *APIConfig) Build() (*commander.Config, error) {
|
||||
if c.Tag == "" {
|
||||
return nil, newError("API tag can't be empty.")
|
||||
}
|
||||
|
||||
services := make([]*serial.TypedMessage, 0, 16)
|
||||
for _, s := range c.Services {
|
||||
switch strings.ToLower(s) {
|
||||
case "reflectionservice":
|
||||
services = append(services, serial.ToTypedMessage(&commander.ReflectionConfig{}))
|
||||
case "handlerservice":
|
||||
services = append(services, serial.ToTypedMessage(&handlerservice.Config{}))
|
||||
case "loggerservice":
|
||||
services = append(services, serial.ToTypedMessage(&loggerservice.Config{}))
|
||||
case "statsservice":
|
||||
services = append(services, serial.ToTypedMessage(&statsservice.Config{}))
|
||||
}
|
||||
}
|
||||
|
||||
return &commander.Config{
|
||||
Tag: c.Tag,
|
||||
Service: services,
|
||||
}, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue