config.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package option
  2. import (
  3. "bytes"
  4. "github.com/sagernet/sing/common/json"
  5. )
  6. type _Options struct {
  7. RawMessage json.RawMessage `json:"-"`
  8. Schema string `json:"$schema,omitempty"`
  9. Log *LogOptions `json:"log,omitempty"`
  10. DNS *DNSOptions `json:"dns,omitempty"`
  11. NTP *NTPOptions `json:"ntp,omitempty"`
  12. Inbounds []Inbound `json:"inbounds,omitempty"`
  13. Outbounds []Outbound `json:"outbounds,omitempty"`
  14. Route *RouteOptions `json:"route,omitempty"`
  15. Experimental *ExperimentalOptions `json:"experimental,omitempty"`
  16. }
  17. type Options _Options
  18. func (o *Options) UnmarshalJSON(content []byte) error {
  19. decoder := json.NewDecoder(bytes.NewReader(content))
  20. decoder.DisallowUnknownFields()
  21. err := decoder.Decode((*_Options)(o))
  22. if err != nil {
  23. return err
  24. }
  25. o.RawMessage = content
  26. return nil
  27. }
  28. type LogOptions struct {
  29. Disabled bool `json:"disabled,omitempty"`
  30. Level string `json:"level,omitempty"`
  31. Output string `json:"output,omitempty"`
  32. Timestamp bool `json:"timestamp,omitempty"`
  33. DisableColor bool `json:"-"`
  34. }