V2bX/conf/core.go

31 lines
587 B
Go
Raw Normal View History

package conf
2023-08-20 03:13:52 -04:00
import (
"encoding/json"
)
type CoreConfig struct {
2023-08-20 03:13:52 -04:00
Type string `json:"Type"`
2023-09-16 08:03:02 -04:00
Name string `json:"Name"`
2023-08-20 03:13:52 -04:00
XrayConfig *XrayConfig `json:"-"`
SingConfig *SingConfig `json:"-"`
}
type _CoreConfig CoreConfig
func (c *CoreConfig) UnmarshalJSON(b []byte) error {
err := json.Unmarshal(b, (*_CoreConfig)(c))
if err != nil {
return err
}
switch c.Type {
case "xray":
c.XrayConfig = NewXrayConfig()
return json.Unmarshal(b, c.XrayConfig)
case "sing":
c.SingConfig = NewSingConfig()
return json.Unmarshal(b, c.SingConfig)
}
return nil
}