Files
sing-box-extended-mirror/option/direct.go
T

40 lines
1.2 KiB
Go
Raw Normal View History

2022-07-25 11:29:46 +08:00
package option
2024-11-14 18:31:37 +08:00
import (
"context"
2026-02-28 17:55:56 +08:00
E "github.com/sagernet/sing/common/exceptions"
2024-11-14 18:31:37 +08:00
"github.com/sagernet/sing/common/json"
)
2022-07-25 11:29:46 +08:00
type DirectInboundOptions struct {
ListenOptions
Network NetworkList `json:"network,omitempty"`
OverrideAddress string `json:"override_address,omitempty"`
OverridePort uint16 `json:"override_port,omitempty"`
}
2024-11-14 18:31:37 +08:00
type _DirectOutboundOptions struct {
2022-09-03 12:55:10 +08:00
DialerOptions
2024-11-14 18:31:37 +08:00
// Deprecated: Use Route Action instead
2022-07-25 11:29:46 +08:00
OverrideAddress string `json:"override_address,omitempty"`
2024-11-14 18:31:37 +08:00
// Deprecated: Use Route Action instead
OverridePort uint16 `json:"override_port,omitempty"`
// Deprecated: removed
ProxyProtocol uint8 `json:"proxy_protocol,omitempty"`
}
type DirectOutboundOptions _DirectOutboundOptions
func (d *DirectOutboundOptions) UnmarshalJSONContext(ctx context.Context, content []byte) error {
err := json.UnmarshalDisallowUnknownFields(content, (*_DirectOutboundOptions)(d))
if err != nil {
return err
}
2026-02-28 17:55:56 +08:00
//nolint:staticcheck
2024-11-14 18:31:37 +08:00
if d.OverrideAddress != "" || d.OverridePort != 0 {
2026-02-28 17:55:56 +08:00
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")
2024-11-14 18:31:37 +08:00
}
return nil
2022-07-25 11:29:46 +08:00
}