Implement new deprecated warnings

This commit is contained in:
世界 2024-11-07 12:02:36 +08:00
parent 313be3d7a4
commit 59a607e303
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
6 changed files with 59 additions and 17 deletions

View file

@ -3,6 +3,8 @@ package option
import (
"context"
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/experimental/deprecated"
E "github.com/sagernet/sing/common/exceptions"
"github.com/sagernet/sing/common/json"
"github.com/sagernet/sing/common/json/badjson"
@ -35,6 +37,10 @@ func (h *Outbound) UnmarshalJSONContext(ctx context.Context, content []byte) err
if registry == nil {
return E.New("missing outbound options registry in context")
}
switch h.Type {
case C.TypeBlock, C.TypeDNS:
deprecated.Report(ctx, deprecated.OptionSpecialOutbounds)
}
options, loaded := registry.CreateOptions(h.Type)
if !loaded {
return E.New("unknown outbound type: ", h.Type)
@ -43,6 +49,11 @@ func (h *Outbound) UnmarshalJSONContext(ctx context.Context, content []byte) err
if err != nil {
return err
}
if listenWrapper, isListen := options.(ListenOptionsWrapper); isListen {
if listenWrapper.TakeListenOptions().InboundOptions != (InboundOptions{}) {
deprecated.Report(ctx, deprecated.OptionInboundOptions)
}
}
h.Options = options
return nil
}