2022-07-02 06:07:50 +00:00
|
|
|
package option
|
|
|
|
|
2022-07-03 03:28:15 +00:00
|
|
|
import (
|
|
|
|
"bytes"
|
2022-07-02 17:57:04 +00:00
|
|
|
|
2023-12-01 12:15:11 +00:00
|
|
|
"github.com/sagernet/sing/common/json"
|
2022-07-03 03:28:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type _Options struct {
|
2023-12-10 14:57:28 +00:00
|
|
|
RawMessage json.RawMessage `json:"-"`
|
2023-03-13 02:58:29 +00:00
|
|
|
Schema string `json:"$schema,omitempty"`
|
2023-02-28 11:02:27 +00:00
|
|
|
Log *LogOptions `json:"log,omitempty"`
|
|
|
|
DNS *DNSOptions `json:"dns,omitempty"`
|
|
|
|
NTP *NTPOptions `json:"ntp,omitempty"`
|
|
|
|
Inbounds []Inbound `json:"inbounds,omitempty"`
|
|
|
|
Outbounds []Outbound `json:"outbounds,omitempty"`
|
|
|
|
Route *RouteOptions `json:"route,omitempty"`
|
|
|
|
Experimental *ExperimentalOptions `json:"experimental,omitempty"`
|
2022-07-02 06:07:50 +00:00
|
|
|
}
|
|
|
|
|
2022-07-03 03:28:15 +00:00
|
|
|
type Options _Options
|
|
|
|
|
|
|
|
func (o *Options) UnmarshalJSON(content []byte) error {
|
2023-12-10 14:57:28 +00:00
|
|
|
decoder := json.NewDecoder(bytes.NewReader(content))
|
2022-07-03 03:28:15 +00:00
|
|
|
decoder.DisallowUnknownFields()
|
2022-07-07 13:47:21 +00:00
|
|
|
err := decoder.Decode((*_Options)(o))
|
2023-12-10 14:57:28 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2022-07-07 13:47:21 +00:00
|
|
|
}
|
2023-12-10 14:57:28 +00:00
|
|
|
o.RawMessage = content
|
|
|
|
return nil
|
2022-07-03 03:28:15 +00:00
|
|
|
}
|
|
|
|
|
2022-07-19 14:16:49 +00:00
|
|
|
type LogOptions struct {
|
2022-07-04 08:45:32 +00:00
|
|
|
Disabled bool `json:"disabled,omitempty"`
|
|
|
|
Level string `json:"level,omitempty"`
|
|
|
|
Output string `json:"output,omitempty"`
|
|
|
|
Timestamp bool `json:"timestamp,omitempty"`
|
|
|
|
DisableColor bool `json:"-"`
|
2022-07-02 06:07:50 +00:00
|
|
|
}
|