mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-12-25 02:05:38 +08:00
49 lines
1.4 KiB
Go
49 lines
1.4 KiB
Go
package option
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
|
|
"github.com/sagernet/sing/common/json"
|
|
)
|
|
|
|
type _Options struct {
|
|
RawMessage json.RawMessage `json:"-"`
|
|
Schema string `json:"$schema,omitempty"`
|
|
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"`
|
|
|
|
// Deprecated: use Inbounds instead
|
|
LegacyInbounds []LegacyInbound `json:"-"`
|
|
// Deprecated: use Outbounds instead
|
|
LegacyOutbounds []LegacyOutbound `json:"-"`
|
|
}
|
|
|
|
type Options _Options
|
|
|
|
func (o *Options) UnmarshalJSONContext(ctx context.Context, content []byte) error {
|
|
decoder := json.NewDecoderContext(ctx, bytes.NewReader(content))
|
|
decoder.DisallowUnknownFields()
|
|
err := decoder.Decode((*_Options)(o))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
o.RawMessage = content
|
|
return nil
|
|
}
|
|
|
|
type LogOptions struct {
|
|
Disabled bool `json:"disabled,omitempty"`
|
|
Level string `json:"level,omitempty"`
|
|
Output string `json:"output,omitempty"`
|
|
Timestamp bool `json:"timestamp,omitempty"`
|
|
DisableColor bool `json:"-"`
|
|
}
|
|
|
|
type StubOptions struct{}
|