direct.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package option
  2. import (
  3. "context"
  4. E "github.com/sagernet/sing/common/exceptions"
  5. "github.com/sagernet/sing/common/json"
  6. )
  7. type DirectInboundOptions struct {
  8. ListenOptions
  9. Network NetworkList `json:"network,omitempty"`
  10. OverrideAddress string `json:"override_address,omitempty"`
  11. OverridePort uint16 `json:"override_port,omitempty"`
  12. }
  13. type _DirectOutboundOptions struct {
  14. DialerOptions
  15. // Deprecated: Use Route Action instead
  16. OverrideAddress string `json:"override_address,omitempty"`
  17. // Deprecated: Use Route Action instead
  18. OverridePort uint16 `json:"override_port,omitempty"`
  19. // Deprecated: removed
  20. ProxyProtocol uint8 `json:"proxy_protocol,omitempty"`
  21. }
  22. type DirectOutboundOptions _DirectOutboundOptions
  23. func (d *DirectOutboundOptions) UnmarshalJSONContext(ctx context.Context, content []byte) error {
  24. err := json.UnmarshalDisallowUnknownFields(content, (*_DirectOutboundOptions)(d))
  25. if err != nil {
  26. return err
  27. }
  28. //nolint:staticcheck
  29. if d.OverrideAddress != "" || d.OverridePort != 0 {
  30. return E.New("destination override fields in direct outbound are deprecated in sing-box 1.11.0 and removed in sing-box 1.13.0, use route options instead")
  31. }
  32. return nil
  33. }