sing-box/option/options.go

49 lines
1.4 KiB
Go
Raw Permalink Normal View History

2022-07-02 14:07:50 +08:00
package option
import (
"bytes"
2024-11-02 00:39:02 +08:00
"context"
2022-07-03 01:57:04 +08:00
"github.com/sagernet/sing/common/json"
)
type _Options struct {
2023-12-10 22:57:28 +08:00
RawMessage json.RawMessage `json:"-"`
2023-03-13 10:58:29 +08:00
Schema string `json:"$schema,omitempty"`
2023-02-28 19:02:27 +08: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"`
2024-11-02 00:39:02 +08:00
// Deprecated: use Inbounds instead
2024-11-06 17:23:00 +08:00
LegacyInbounds []LegacyInbound `json:"-"`
2024-11-02 00:39:02 +08:00
// Deprecated: use Outbounds instead
2024-11-06 17:23:00 +08:00
LegacyOutbounds []LegacyOutbound `json:"-"`
2022-07-02 14:07:50 +08:00
}
type Options _Options
2024-11-02 00:39:02 +08:00
func (o *Options) UnmarshalJSONContext(ctx context.Context, content []byte) error {
decoder := json.NewDecoderContext(ctx, bytes.NewReader(content))
decoder.DisallowUnknownFields()
2022-07-07 21:47:21 +08:00
err := decoder.Decode((*_Options)(o))
2023-12-10 22:57:28 +08:00
if err != nil {
return err
2022-07-07 21:47:21 +08:00
}
2023-12-10 22:57:28 +08:00
o.RawMessage = content
return nil
}
2022-07-19 22:16:49 +08:00
type LogOptions 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
}
2024-11-02 00:39:02 +08:00
type StubOptions struct{}