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