2022-07-02 14:07:50 +08:00
|
|
|
package option
|
|
|
|
|
2022-07-03 11:28:15 +08:00
|
|
|
import (
|
|
|
|
"bytes"
|
2022-07-03 01:57:04 +08:00
|
|
|
|
2022-07-03 11:28:15 +08:00
|
|
|
"github.com/sagernet/sing/common"
|
2022-07-06 15:01:09 +08:00
|
|
|
|
|
|
|
"github.com/goccy/go-json"
|
2022-07-03 11:28:15 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type _Options struct {
|
2022-07-03 03:42:57 +08:00
|
|
|
Log *LogOption `json:"log,omitempty"`
|
2022-07-02 22:55:10 +08:00
|
|
|
Inbounds []Inbound `json:"inbounds,omitempty"`
|
|
|
|
Outbounds []Outbound `json:"outbounds,omitempty"`
|
|
|
|
Route *RouteOptions `json:"route,omitempty"`
|
2022-07-02 14:07:50 +08:00
|
|
|
}
|
|
|
|
|
2022-07-03 11:28:15 +08:00
|
|
|
type Options _Options
|
|
|
|
|
|
|
|
func (o *Options) UnmarshalJSON(content []byte) error {
|
|
|
|
decoder := json.NewDecoder(bytes.NewReader(content))
|
|
|
|
decoder.DisallowUnknownFields()
|
|
|
|
return decoder.Decode((*_Options)(o))
|
|
|
|
}
|
|
|
|
|
2022-07-03 01:57:04 +08:00
|
|
|
func (o Options) Equals(other Options) bool {
|
|
|
|
return common.ComparablePtrEquals(o.Log, other.Log) &&
|
|
|
|
common.SliceEquals(o.Inbounds, other.Inbounds) &&
|
|
|
|
common.ComparableSliceEquals(o.Outbounds, other.Outbounds) &&
|
|
|
|
common.PtrEquals(o.Route, other.Route)
|
|
|
|
}
|
|
|
|
|
2022-07-02 14:07:50 +08:00
|
|
|
type LogOption struct {
|
2022-07-04 16:45:32 +08: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 14:07:50 +08:00
|
|
|
}
|