From 8ae93a98e581d9a89f0019cbf3101301c2d411b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 28 Feb 2026 17:55:56 +0800 Subject: [PATCH] Remove overdue deprecated features --- adapter/inbound.go | 11 +- common/listener/listener_tcp.go | 2 - common/tls/ech.go | 5 +- experimental/deprecated/constants.go | 110 ---------------- include/registry.go | 6 +- include/wireguard.go | 5 - include/wireguard_stub.go | 7 - option/direct.go | 5 +- option/inbound.go | 2 +- option/outbound.go | 6 +- option/wireguard.go | 25 ---- protocol/anytls/inbound.go | 1 - protocol/direct/inbound.go | 1 - protocol/direct/outbound.go | 89 ++----------- protocol/hysteria/inbound.go | 2 - protocol/hysteria2/inbound.go | 2 - protocol/naive/inbound.go | 1 - protocol/shadowsocks/inbound_multi.go | 2 - protocol/shadowsocks/inbound_relay.go | 2 - protocol/shadowtls/inbound.go | 1 - protocol/trojan/inbound.go | 1 - protocol/tuic/inbound.go | 2 - protocol/tun/inbound.go | 106 +++++----------- protocol/vless/inbound.go | 1 - protocol/vmess/inbound.go | 1 - protocol/wireguard/outbound.go | 176 -------------------------- route/route.go | 32 ----- route/rule/rule_default.go | 10 +- route/rule/rule_dns.go | 10 +- test/domain_inbound_test.go | 3 - test/inbound_detour_test.go | 4 +- test/shadowtls_test.go | 9 +- 32 files changed, 67 insertions(+), 573 deletions(-) delete mode 100644 protocol/wireguard/outbound.go diff --git a/adapter/inbound.go b/adapter/inbound.go index 1941df5b6..b32e9f827 100644 --- a/adapter/inbound.go +++ b/adapter/inbound.go @@ -62,13 +62,10 @@ type InboundContext struct { // cache // Deprecated: implement in rule action - InboundDetour string - LastInbound string - OriginDestination M.Socksaddr - RouteOriginalDestination M.Socksaddr - // Deprecated: to be removed - //nolint:staticcheck - InboundOptions option.InboundOptions + InboundDetour string + LastInbound string + OriginDestination M.Socksaddr + RouteOriginalDestination M.Socksaddr UDPDisableDomainUnmapping bool UDPConnect bool UDPTimeout time.Duration diff --git a/common/listener/listener_tcp.go b/common/listener/listener_tcp.go index 2164ff8e1..899d444fe 100644 --- a/common/listener/listener_tcp.go +++ b/common/listener/listener_tcp.go @@ -99,8 +99,6 @@ func (l *Listener) loopTCPIn() { } //nolint:staticcheck metadata.InboundDetour = l.listenOptions.Detour - //nolint:staticcheck - metadata.InboundOptions = l.listenOptions.InboundOptions metadata.Source = M.SocksaddrFromNet(conn.RemoteAddr()).Unwrap() metadata.OriginDestination = M.SocksaddrFromNet(conn.LocalAddr()).Unwrap() ctx := log.ContextWithNewID(l.ctx) diff --git a/common/tls/ech.go b/common/tls/ech.go index 37573bf13..8c884cab6 100644 --- a/common/tls/ech.go +++ b/common/tls/ech.go @@ -15,7 +15,6 @@ import ( "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/dns" - "github.com/sagernet/sing-box/experimental/deprecated" "github.com/sagernet/sing-box/option" E "github.com/sagernet/sing/common/exceptions" aTLS "github.com/sagernet/sing/common/tls" @@ -38,7 +37,7 @@ func parseECHClientConfig(ctx context.Context, clientConfig ECHCapableConfig, op } //nolint:staticcheck if options.ECH.PQSignatureSchemesEnabled || options.ECH.DynamicRecordSizingDisabled { - deprecated.Report(ctx, deprecated.OptionLegacyECHOptions) + return nil, E.New("legacy ECH options are deprecated in sing-box 1.12.0 and removed in sing-box 1.13.0") } if len(echConfig) > 0 { block, rest := pem.Decode(echConfig) @@ -77,7 +76,7 @@ func parseECHServerConfig(ctx context.Context, options option.InboundTLSOptions, tlsConfig.EncryptedClientHelloKeys = echKeys //nolint:staticcheck if options.ECH.PQSignatureSchemesEnabled || options.ECH.DynamicRecordSizingDisabled { - deprecated.Report(ctx, deprecated.OptionLegacyECHOptions) + return E.New("legacy ECH options are deprecated in sing-box 1.12.0 and removed in sing-box 1.13.0") } return nil } diff --git a/experimental/deprecated/constants.go b/experimental/deprecated/constants.go index 5dfdfd475..385105d38 100644 --- a/experimental/deprecated/constants.go +++ b/experimental/deprecated/constants.go @@ -57,96 +57,6 @@ func (n Note) MessageWithLink() string { } } -var OptionBadMatchSource = Note{ - Name: "bad-match-source", - Description: "legacy match source rule item", - DeprecatedVersion: "1.10.0", - ScheduledVersion: "1.11.0", - EnvName: "BAD_MATCH_SOURCE", - MigrationLink: "https://sing-box.sagernet.org/deprecated/#match-source-rule-items-are-renamed", -} - -var OptionGEOIP = Note{ - Name: "geoip", - Description: "geoip database", - DeprecatedVersion: "1.8.0", - ScheduledVersion: "1.12.0", - EnvName: "GEOIP", - MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-geoip-to-rule-sets", -} - -var OptionGEOSITE = Note{ - Name: "geosite", - Description: "geosite database", - DeprecatedVersion: "1.8.0", - ScheduledVersion: "1.12.0", - EnvName: "GEOSITE", - MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-geosite-to-rule-sets", -} - -var OptionTUNAddressX = Note{ - Name: "tun-address-x", - Description: "legacy tun address fields", - DeprecatedVersion: "1.10.0", - ScheduledVersion: "1.12.0", - EnvName: "TUN_ADDRESS_X", - MigrationLink: "https://sing-box.sagernet.org/migration/#tun-address-fields-are-merged", -} - -var OptionSpecialOutbounds = Note{ - Name: "special-outbounds", - Description: "legacy special outbounds", - DeprecatedVersion: "1.11.0", - ScheduledVersion: "1.13.0", - EnvName: "SPECIAL_OUTBOUNDS", - MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-legacy-special-outbounds-to-rule-actions", -} - -var OptionInboundOptions = Note{ - Name: "inbound-options", - Description: "legacy inbound fields", - DeprecatedVersion: "1.11.0", - ScheduledVersion: "1.13.0", - EnvName: "INBOUND_OPTIONS", - MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-legacy-special-outbounds-to-rule-actions", -} - -var OptionDestinationOverrideFields = Note{ - Name: "destination-override-fields", - Description: "destination override fields in direct outbound", - DeprecatedVersion: "1.11.0", - ScheduledVersion: "1.13.0", - EnvName: "DESTINATION_OVERRIDE_FIELDS", - MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-destination-override-fields-to-route-options", -} - -var OptionWireGuardOutbound = Note{ - Name: "wireguard-outbound", - Description: "legacy wireguard outbound", - DeprecatedVersion: "1.11.0", - ScheduledVersion: "1.13.0", - EnvName: "WIREGUARD_OUTBOUND", - MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-wireguard-outbound-to-endpoint", -} - -var OptionWireGuardGSO = Note{ - Name: "wireguard-gso", - Description: "GSO option in wireguard outbound", - DeprecatedVersion: "1.11.0", - ScheduledVersion: "1.13.0", - EnvName: "WIREGUARD_GSO", - MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-wireguard-outbound-to-endpoint", -} - -var OptionTUNGSO = Note{ - Name: "tun-gso", - Description: "GSO option in tun", - DeprecatedVersion: "1.11.0", - ScheduledVersion: "1.12.0", - EnvName: "TUN_GSO", - MigrationLink: "https://sing-box.sagernet.org/deprecated/#gso-option-in-tun", -} - var OptionLegacyDNSTransport = Note{ Name: "legacy-dns-transport", Description: "legacy DNS servers", @@ -183,15 +93,6 @@ var OptionMissingDomainResolver = Note{ MigrationLink: "https://sing-box.sagernet.org/migration/#migrate-outbound-dns-rule-items-to-domain-resolver", } -var OptionLegacyECHOptions = Note{ - Name: "legacy-ech-options", - Description: "legacy ECH options", - DeprecatedVersion: "1.12.0", - ScheduledVersion: "1.13.0", - EnvName: "LEGACY_ECH_OPTIONS", - MigrationLink: "https://sing-box.sagernet.org/deprecated/#legacy-ech-fields", -} - var OptionLegacyDomainStrategyOptions = Note{ Name: "legacy-domain-strategy-options", Description: "legacy domain strategy options", @@ -202,20 +103,9 @@ var OptionLegacyDomainStrategyOptions = Note{ } var Options = []Note{ - OptionBadMatchSource, - OptionGEOIP, - OptionGEOSITE, - OptionTUNAddressX, - OptionSpecialOutbounds, - OptionInboundOptions, - OptionDestinationOverrideFields, - OptionWireGuardOutbound, - OptionWireGuardGSO, - OptionTUNGSO, OptionLegacyDNSTransport, OptionLegacyDNSFakeIPOptions, OptionOutboundDNSRuleItem, OptionMissingDomainResolver, - OptionLegacyECHOptions, OptionLegacyDomainStrategyOptions, } diff --git a/include/registry.go b/include/registry.go index 64a49b61a..f090845b5 100644 --- a/include/registry.go +++ b/include/registry.go @@ -20,7 +20,6 @@ import ( "github.com/sagernet/sing-box/protocol/anytls" "github.com/sagernet/sing-box/protocol/block" "github.com/sagernet/sing-box/protocol/direct" - protocolDNS "github.com/sagernet/sing-box/protocol/dns" "github.com/sagernet/sing-box/protocol/group" "github.com/sagernet/sing-box/protocol/http" "github.com/sagernet/sing-box/protocol/mixed" @@ -76,7 +75,6 @@ func OutboundRegistry() *outbound.Registry { direct.RegisterOutbound(registry) block.RegisterOutbound(registry) - protocolDNS.RegisterOutbound(registry) group.RegisterSelector(registry) group.RegisterURLTest(registry) @@ -94,7 +92,6 @@ func OutboundRegistry() *outbound.Registry { anytls.RegisterOutbound(registry) registerQUICOutbounds(registry) - registerWireGuardOutbound(registry) registerStubForRemovedOutbounds(registry) return registry @@ -152,4 +149,7 @@ func registerStubForRemovedOutbounds(registry *outbound.Registry) { outbound.Register[option.ShadowsocksROutboundOptions](registry, C.TypeShadowsocksR, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.ShadowsocksROutboundOptions) (adapter.Outbound, error) { return nil, E.New("ShadowsocksR is deprecated and removed in sing-box 1.6.0") }) + outbound.Register[option.StubOptions](registry, C.TypeWireGuard, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.StubOptions) (adapter.Outbound, error) { + return nil, E.New("WireGuard outbound is deprecated in sing-box 1.11.0 and removed in sing-box 1.13.0, use WireGuard endpoint instead") + }) } diff --git a/include/wireguard.go b/include/wireguard.go index f2ce9e234..fa7cfe6fd 100644 --- a/include/wireguard.go +++ b/include/wireguard.go @@ -4,14 +4,9 @@ package include import ( "github.com/sagernet/sing-box/adapter/endpoint" - "github.com/sagernet/sing-box/adapter/outbound" "github.com/sagernet/sing-box/protocol/wireguard" ) -func registerWireGuardOutbound(registry *outbound.Registry) { - wireguard.RegisterOutbound(registry) -} - func registerWireGuardEndpoint(registry *endpoint.Registry) { wireguard.RegisterEndpoint(registry) } diff --git a/include/wireguard_stub.go b/include/wireguard_stub.go index 247546e26..e03a9d9c0 100644 --- a/include/wireguard_stub.go +++ b/include/wireguard_stub.go @@ -7,19 +7,12 @@ import ( "github.com/sagernet/sing-box/adapter" "github.com/sagernet/sing-box/adapter/endpoint" - "github.com/sagernet/sing-box/adapter/outbound" C "github.com/sagernet/sing-box/constant" "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" E "github.com/sagernet/sing/common/exceptions" ) -func registerWireGuardOutbound(registry *outbound.Registry) { - outbound.Register[option.LegacyWireGuardOutboundOptions](registry, C.TypeWireGuard, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.LegacyWireGuardOutboundOptions) (adapter.Outbound, error) { - return nil, E.New(`WireGuard is not included in this build, rebuild with -tags with_wireguard`) - }) -} - func registerWireGuardEndpoint(registry *endpoint.Registry) { endpoint.Register[option.WireGuardEndpointOptions](registry, C.TypeWireGuard, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.WireGuardEndpointOptions) (adapter.Endpoint, error) { return nil, E.New(`WireGuard is not included in this build, rebuild with -tags with_wireguard`) diff --git a/option/direct.go b/option/direct.go index 180ff0aa2..a03f98d41 100644 --- a/option/direct.go +++ b/option/direct.go @@ -3,7 +3,7 @@ package option import ( "context" - "github.com/sagernet/sing-box/experimental/deprecated" + E "github.com/sagernet/sing/common/exceptions" "github.com/sagernet/sing/common/json" ) @@ -31,8 +31,9 @@ func (d *DirectOutboundOptions) UnmarshalJSONContext(ctx context.Context, conten if err != nil { return err } + //nolint:staticcheck if d.OverrideAddress != "" || d.OverridePort != 0 { - deprecated.Report(ctx, deprecated.OptionDestinationOverrideFields) + 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") } return nil } diff --git a/option/inbound.go b/option/inbound.go index 42930eccb..4fb6081dc 100644 --- a/option/inbound.go +++ b/option/inbound.go @@ -55,7 +55,6 @@ type InboundOptions struct { SniffTimeout badoption.Duration `json:"sniff_timeout,omitempty"` DomainStrategy DomainStrategy `json:"domain_strategy,omitempty"` UDPDisableDomainUnmapping bool `json:"udp_disable_domain_unmapping,omitempty"` - Detour string `json:"detour,omitempty"` } type ListenOptions struct { @@ -73,6 +72,7 @@ type ListenOptions struct { UDPFragment *bool `json:"udp_fragment,omitempty"` UDPFragmentDefault bool `json:"-"` UDPTimeout UDPTimeoutCompat `json:"udp_timeout,omitempty"` + Detour string `json:"detour,omitempty"` // Deprecated: removed ProxyProtocol bool `json:"proxy_protocol,omitempty"` diff --git a/option/outbound.go b/option/outbound.go index 2ed7cf2eb..cb388c443 100644 --- a/option/outbound.go +++ b/option/outbound.go @@ -4,7 +4,6 @@ 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" @@ -40,7 +39,7 @@ func (h *Outbound) UnmarshalJSONContext(ctx context.Context, content []byte) err } switch h.Type { case C.TypeDNS: - deprecated.Report(ctx, deprecated.OptionSpecialOutbounds) + return E.New("dns outbound is deprecated in sing-box 1.11.0 and removed in sing-box 1.13.0, use rule actions instead") } options, loaded := registry.CreateOptions(h.Type) if !loaded { @@ -51,8 +50,9 @@ func (h *Outbound) UnmarshalJSONContext(ctx context.Context, content []byte) err return err } if listenWrapper, isListen := options.(ListenOptionsWrapper); isListen { + //nolint:staticcheck if listenWrapper.TakeListenOptions().InboundOptions != (InboundOptions{}) { - deprecated.Report(ctx, deprecated.OptionInboundOptions) + return E.New("legacy inbound fields are deprecated in sing-box 1.11.0 and removed in sing-box 1.13.0, use rule actions instead") } } h.Options = options diff --git a/option/wireguard.go b/option/wireguard.go index 43d3139c5..c86abd112 100644 --- a/option/wireguard.go +++ b/option/wireguard.go @@ -28,28 +28,3 @@ type WireGuardPeer struct { PersistentKeepaliveInterval uint16 `json:"persistent_keepalive_interval,omitempty"` Reserved []uint8 `json:"reserved,omitempty"` } - -type LegacyWireGuardOutboundOptions struct { - DialerOptions - SystemInterface bool `json:"system_interface,omitempty"` - GSO bool `json:"gso,omitempty"` - InterfaceName string `json:"interface_name,omitempty"` - LocalAddress badoption.Listable[netip.Prefix] `json:"local_address"` - PrivateKey string `json:"private_key"` - Peers []LegacyWireGuardPeer `json:"peers,omitempty"` - ServerOptions - PeerPublicKey string `json:"peer_public_key"` - PreSharedKey string `json:"pre_shared_key,omitempty"` - Reserved []uint8 `json:"reserved,omitempty"` - Workers int `json:"workers,omitempty"` - MTU uint32 `json:"mtu,omitempty"` - Network NetworkList `json:"network,omitempty"` -} - -type LegacyWireGuardPeer struct { - ServerOptions - PublicKey string `json:"public_key,omitempty"` - PreSharedKey string `json:"pre_shared_key,omitempty"` - AllowedIPs badoption.Listable[netip.Prefix] `json:"allowed_ips,omitempty"` - Reserved []uint8 `json:"reserved,omitempty"` -} diff --git a/protocol/anytls/inbound.go b/protocol/anytls/inbound.go index 662c77887..52d773537 100644 --- a/protocol/anytls/inbound.go +++ b/protocol/anytls/inbound.go @@ -122,7 +122,6 @@ func (h *inboundHandler) NewConnectionEx(ctx context.Context, conn net.Conn, sou //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions metadata.Source = source metadata.Destination = destination.Unwrap() if userName, _ := auth.UserFromContext[string](ctx); userName != "" { diff --git a/protocol/direct/inbound.go b/protocol/direct/inbound.go index a96e8326a..81353b659 100644 --- a/protocol/direct/inbound.go +++ b/protocol/direct/inbound.go @@ -111,7 +111,6 @@ func (i *Inbound) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, //nolint:staticcheck metadata.InboundDetour = i.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = i.listener.ListenOptions().InboundOptions metadata.Source = source destination = i.listener.UDPAddr() switch i.overrideOption { diff --git a/protocol/direct/outbound.go b/protocol/direct/outbound.go index 1f24f0c9c..9d24f31af 100644 --- a/protocol/direct/outbound.go +++ b/protocol/direct/outbound.go @@ -16,7 +16,6 @@ import ( "github.com/sagernet/sing-tun" "github.com/sagernet/sing-tun/ping" "github.com/sagernet/sing/common" - "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" "github.com/sagernet/sing/common/logger" M "github.com/sagernet/sing/common/metadata" @@ -36,14 +35,12 @@ var ( type Outbound struct { outbound.Adapter - ctx context.Context - logger logger.ContextLogger - dialer dialer.ParallelInterfaceDialer - domainStrategy C.DomainStrategy - fallbackDelay time.Duration - overrideOption int - overrideDestination M.Socksaddr - isEmpty bool + ctx context.Context + logger logger.ContextLogger + dialer dialer.ParallelInterfaceDialer + domainStrategy C.DomainStrategy + fallbackDelay time.Duration + isEmpty bool // loopBack *loopBackDetector } @@ -69,25 +66,13 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL domainStrategy: C.DomainStrategy(options.DomainStrategy), fallbackDelay: time.Duration(options.FallbackDelay), dialer: outboundDialer.(dialer.ParallelInterfaceDialer), - //nolint:staticcheck - isEmpty: reflect.DeepEqual(options.DialerOptions, option.DialerOptions{UDPFragmentDefault: true}) && options.OverrideAddress == "" && options.OverridePort == 0, + isEmpty: reflect.DeepEqual(options.DialerOptions, option.DialerOptions{UDPFragmentDefault: true}), // loopBack: newLoopBackDetector(router), } //nolint:staticcheck if options.ProxyProtocol != 0 { return nil, E.New("Proxy Protocol is deprecated and removed in sing-box 1.6.0") } - //nolint:staticcheck - if options.OverrideAddress != "" && options.OverridePort != 0 { - outbound.overrideOption = 1 - outbound.overrideDestination = M.ParseSocksaddrHostPort(options.OverrideAddress, options.OverridePort) - } else if options.OverrideAddress != "" { - outbound.overrideOption = 2 - outbound.overrideDestination = M.ParseSocksaddrHostPort(options.OverrideAddress, options.OverridePort) - } else if options.OverridePort != 0 { - outbound.overrideOption = 3 - outbound.overrideDestination = M.Socksaddr{Port: options.OverridePort} - } return outbound, nil } @@ -95,16 +80,6 @@ func (h *Outbound) DialContext(ctx context.Context, network string, destination ctx, metadata := adapter.ExtendContext(ctx) metadata.Outbound = h.Tag() metadata.Destination = destination - switch h.overrideOption { - case 1: - destination = h.overrideDestination - case 2: - newDestination := h.overrideDestination - newDestination.Port = destination.Port - destination = newDestination - case 3: - destination.Port = h.overrideDestination.Port - } network = N.NetworkName(network) switch network { case N.NetworkTCP: @@ -124,30 +99,12 @@ func (h *Outbound) ListenPacket(ctx context.Context, destination M.Socksaddr) (n ctx, metadata := adapter.ExtendContext(ctx) metadata.Outbound = h.Tag() metadata.Destination = destination - originDestination := destination - switch h.overrideOption { - case 1: - destination = h.overrideDestination - case 2: - newDestination := h.overrideDestination - newDestination.Port = destination.Port - destination = newDestination - case 3: - destination.Port = h.overrideDestination.Port - } - if h.overrideOption == 0 { - h.logger.InfoContext(ctx, "outbound packet connection") - } else { - h.logger.InfoContext(ctx, "outbound packet connection to ", destination) - } + h.logger.InfoContext(ctx, "outbound packet connection") conn, err := h.dialer.ListenPacket(ctx, destination) if err != nil { return nil, err } // conn = h.loopBack.NewPacketConn(bufio.NewPacketConn(conn), destination) - if originDestination != destination { - conn = bufio.NewNATPacketConn(bufio.NewPacketConn(conn), destination, originDestination) - } return conn, nil } @@ -165,13 +122,6 @@ func (h *Outbound) DialParallel(ctx context.Context, network string, destination ctx, metadata := adapter.ExtendContext(ctx) metadata.Outbound = h.Tag() metadata.Destination = destination - switch h.overrideOption { - case 1, 2: - // override address - return h.DialContext(ctx, network, destination) - case 3: - destination.Port = h.overrideDestination.Port - } network = N.NetworkName(network) switch network { case N.NetworkTCP: @@ -186,13 +136,6 @@ func (h *Outbound) DialParallelNetwork(ctx context.Context, network string, dest ctx, metadata := adapter.ExtendContext(ctx) metadata.Outbound = h.Tag() metadata.Destination = destination - switch h.overrideOption { - case 1, 2: - // override address - return h.DialContext(ctx, network, destination) - case 3: - destination.Port = h.overrideDestination.Port - } network = N.NetworkName(network) switch network { case N.NetworkTCP: @@ -207,21 +150,7 @@ func (h *Outbound) ListenSerialNetworkPacket(ctx context.Context, destination M. ctx, metadata := adapter.ExtendContext(ctx) metadata.Outbound = h.Tag() metadata.Destination = destination - switch h.overrideOption { - case 1: - destination = h.overrideDestination - case 2: - newDestination := h.overrideDestination - newDestination.Port = destination.Port - destination = newDestination - case 3: - destination.Port = h.overrideDestination.Port - } - if h.overrideOption == 0 { - h.logger.InfoContext(ctx, "outbound packet connection") - } else { - h.logger.InfoContext(ctx, "outbound packet connection to ", destination) - } + h.logger.InfoContext(ctx, "outbound packet connection") conn, newDestination, err := dialer.ListenSerialNetworkPacket(ctx, h.dialer, destination, destinationAddresses, networkStrategy, networkType, fallbackNetworkType, fallbackDelay) if err != nil { return nil, netip.Addr{}, err diff --git a/protocol/hysteria/inbound.go b/protocol/hysteria/inbound.go index 5afc440d3..98d7cb810 100644 --- a/protocol/hysteria/inbound.go +++ b/protocol/hysteria/inbound.go @@ -118,7 +118,6 @@ func (h *Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, source M.S //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions metadata.OriginDestination = h.listener.UDPAddr() metadata.Source = source metadata.Destination = destination @@ -141,7 +140,6 @@ func (h *Inbound) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions metadata.OriginDestination = h.listener.UDPAddr() metadata.Source = source metadata.Destination = destination diff --git a/protocol/hysteria2/inbound.go b/protocol/hysteria2/inbound.go index f55b6ae87..bb5980701 100644 --- a/protocol/hysteria2/inbound.go +++ b/protocol/hysteria2/inbound.go @@ -151,7 +151,6 @@ func (h *Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, source M.S //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions metadata.OriginDestination = h.listener.UDPAddr() metadata.Source = source metadata.Destination = destination @@ -174,7 +173,6 @@ func (h *Inbound) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions metadata.OriginDestination = h.listener.UDPAddr() metadata.Source = source metadata.Destination = destination diff --git a/protocol/naive/inbound.go b/protocol/naive/inbound.go index 839385947..48c35926a 100644 --- a/protocol/naive/inbound.go +++ b/protocol/naive/inbound.go @@ -209,7 +209,6 @@ func (n *Inbound) newConnection(ctx context.Context, waitForClose bool, conn net //nolint:staticcheck metadata.InboundDetour = n.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = n.listener.ListenOptions().InboundOptions metadata.Source = source metadata.Destination = destination metadata.OriginDestination = M.SocksaddrFromNet(conn.LocalAddr()).Unwrap() diff --git a/protocol/shadowsocks/inbound_multi.go b/protocol/shadowsocks/inbound_multi.go index 0120a08a0..7ff926469 100644 --- a/protocol/shadowsocks/inbound_multi.go +++ b/protocol/shadowsocks/inbound_multi.go @@ -175,7 +175,6 @@ func (h *MultiInbound) newConnection(ctx context.Context, conn net.Conn, metadat //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions if h.tracker != nil { conn = h.tracker.TrackConnection(conn, metadata) } @@ -201,7 +200,6 @@ func (h *MultiInbound) newPacketConnection(ctx context.Context, conn N.PacketCon //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions if h.tracker != nil { conn = h.tracker.TrackPacketConnection(conn, metadata) } diff --git a/protocol/shadowsocks/inbound_relay.go b/protocol/shadowsocks/inbound_relay.go index 9760b2f0e..d7d7bcff7 100644 --- a/protocol/shadowsocks/inbound_relay.go +++ b/protocol/shadowsocks/inbound_relay.go @@ -135,7 +135,6 @@ func (h *RelayInbound) newConnection(ctx context.Context, conn net.Conn, metadat //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions return h.router.RouteConnection(ctx, conn, metadata) } @@ -158,7 +157,6 @@ func (h *RelayInbound) newPacketConnection(ctx context.Context, conn N.PacketCon //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions return h.router.RoutePacketConnection(ctx, conn, metadata) } diff --git a/protocol/shadowtls/inbound.go b/protocol/shadowtls/inbound.go index 812df1efc..17afa2683 100644 --- a/protocol/shadowtls/inbound.go +++ b/protocol/shadowtls/inbound.go @@ -129,7 +129,6 @@ func (h *inboundHandler) NewConnectionEx(ctx context.Context, conn net.Conn, sou //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions metadata.Source = source metadata.Destination = destination if userName, _ := auth.UserFromContext[string](ctx); userName != "" { diff --git a/protocol/trojan/inbound.go b/protocol/trojan/inbound.go index 24e8a023c..6e11c0889 100644 --- a/protocol/trojan/inbound.go +++ b/protocol/trojan/inbound.go @@ -257,7 +257,6 @@ func (h *inboundTransportHandler) NewConnectionEx(ctx context.Context, conn net. //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions h.logger.InfoContext(ctx, "inbound connection from ", metadata.Source) (*Inbound)(h).NewConnectionEx(ctx, conn, metadata, onClose) } diff --git a/protocol/tuic/inbound.go b/protocol/tuic/inbound.go index c4c632363..600c7f93a 100644 --- a/protocol/tuic/inbound.go +++ b/protocol/tuic/inbound.go @@ -108,7 +108,6 @@ func (h *Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, source M.S //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions metadata.OriginDestination = h.listener.UDPAddr() metadata.Source = source metadata.Destination = destination @@ -131,7 +130,6 @@ func (h *Inbound) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions metadata.OriginDestination = h.listener.UDPAddr() metadata.Source = source metadata.Destination = destination diff --git a/protocol/tun/inbound.go b/protocol/tun/inbound.go index 70f820442..df9344b81 100644 --- a/protocol/tun/inbound.go +++ b/protocol/tun/inbound.go @@ -14,7 +14,6 @@ import ( "github.com/sagernet/sing-box/adapter/inbound" "github.com/sagernet/sing-box/common/taskmonitor" C "github.com/sagernet/sing-box/constant" - "github.com/sagernet/sing-box/experimental/deprecated" "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing-box/route/rule" @@ -36,13 +35,11 @@ func RegisterInbound(registry *inbound.Registry) { } type Inbound struct { - tag string - ctx context.Context - router adapter.Router - networkManager adapter.NetworkManager - logger log.ContextLogger - //nolint:staticcheck - inboundOptions option.InboundOptions + tag string + ctx context.Context + router adapter.Router + networkManager adapter.NetworkManager + logger log.ContextLogger tunOptions tun.Options udpTimeout time.Duration stack string @@ -60,20 +57,18 @@ type Inbound struct { } func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.TunInboundOptions) (adapter.Inbound, error) { + //nolint:staticcheck + if len(options.Inet4Address) > 0 || len(options.Inet6Address) > 0 || + len(options.Inet4RouteAddress) > 0 || len(options.Inet6RouteAddress) > 0 || + len(options.Inet4RouteExcludeAddress) > 0 || len(options.Inet6RouteExcludeAddress) > 0 { + return nil, E.New("legacy tun address fields are deprecated in sing-box 1.10.0 and removed in sing-box 1.12.0") + } + //nolint:staticcheck + if options.GSO { + return nil, E.New("GSO option in tun is deprecated in sing-box 1.11.0 and removed in sing-box 1.12.0") + } + address := options.Address - var deprecatedAddressUsed bool - - //nolint:staticcheck - if len(options.Inet4Address) > 0 { - address = append(address, options.Inet4Address...) - deprecatedAddressUsed = true - } - - //nolint:staticcheck - if len(options.Inet6Address) > 0 { - address = append(address, options.Inet6Address...) - deprecatedAddressUsed = true - } inet4Address := common.Filter(address, func(it netip.Prefix) bool { return it.Addr().Is4() }) @@ -82,18 +77,6 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo }) routeAddress := options.RouteAddress - - //nolint:staticcheck - if len(options.Inet4RouteAddress) > 0 { - routeAddress = append(routeAddress, options.Inet4RouteAddress...) - deprecatedAddressUsed = true - } - - //nolint:staticcheck - if len(options.Inet6RouteAddress) > 0 { - routeAddress = append(routeAddress, options.Inet6RouteAddress...) - deprecatedAddressUsed = true - } inet4RouteAddress := common.Filter(routeAddress, func(it netip.Prefix) bool { return it.Addr().Is4() }) @@ -102,18 +85,6 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo }) routeExcludeAddress := options.RouteExcludeAddress - - //nolint:staticcheck - if len(options.Inet4RouteExcludeAddress) > 0 { - routeExcludeAddress = append(routeExcludeAddress, options.Inet4RouteExcludeAddress...) - deprecatedAddressUsed = true - } - - //nolint:staticcheck - if len(options.Inet6RouteExcludeAddress) > 0 { - routeExcludeAddress = append(routeExcludeAddress, options.Inet6RouteExcludeAddress...) - deprecatedAddressUsed = true - } inet4RouteExcludeAddress := common.Filter(routeExcludeAddress, func(it netip.Prefix) bool { return it.Addr().Is4() }) @@ -121,15 +92,6 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo return it.Addr().Is6() }) - if deprecatedAddressUsed { - deprecated.Report(ctx, deprecated.OptionTUNAddressX) - } - - //nolint:staticcheck - if options.GSO { - deprecated.Report(ctx, deprecated.OptionTUNGSO) - } - platformInterface := service.FromContext[adapter.PlatformInterface](ctx) tunMTU := options.MTU enableGSO := C.IsLinux && options.Stack == "gvisor" && platformInterface == nil && tunMTU > 0 && tunMTU < 49152 @@ -202,7 +164,6 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo router: router, networkManager: networkManager, logger: logger, - inboundOptions: options.InboundOptions, tunOptions: tun.Options{ Name: options.InterfaceName, MTU: tunMTU, @@ -478,13 +439,12 @@ func (t *Inbound) PrepareConnection(network string, source M.Socksaddr, destinat ipVersion = 6 } routeDestination, err := t.router.PreMatch(adapter.InboundContext{ - Inbound: t.tag, - InboundType: C.TypeTun, - IPVersion: ipVersion, - Network: network, - Source: source, - Destination: destination, - InboundOptions: t.inboundOptions, + Inbound: t.tag, + InboundType: C.TypeTun, + IPVersion: ipVersion, + Network: network, + Source: source, + Destination: destination, }, routeContext, timeout, false) if err != nil { switch { @@ -508,8 +468,7 @@ func (t *Inbound) NewConnectionEx(ctx context.Context, conn net.Conn, source M.S metadata.InboundType = C.TypeTun metadata.Source = source metadata.Destination = destination - //nolint:staticcheck - metadata.InboundOptions = t.inboundOptions + t.logger.InfoContext(ctx, "inbound connection from ", metadata.Source) t.logger.InfoContext(ctx, "inbound connection to ", metadata.Destination) t.router.RouteConnectionEx(ctx, conn, metadata, onClose) @@ -522,8 +481,7 @@ func (t *Inbound) NewPacketConnectionEx(ctx context.Context, conn N.PacketConn, metadata.InboundType = C.TypeTun metadata.Source = source metadata.Destination = destination - //nolint:staticcheck - metadata.InboundOptions = t.inboundOptions + t.logger.InfoContext(ctx, "inbound packet connection from ", metadata.Source) t.logger.InfoContext(ctx, "inbound packet connection to ", metadata.Destination) t.router.RoutePacketConnectionEx(ctx, conn, metadata, onClose) @@ -539,13 +497,12 @@ func (t *autoRedirectHandler) PrepareConnection(network string, source M.Socksad ipVersion = 6 } routeDestination, err := t.router.PreMatch(adapter.InboundContext{ - Inbound: t.tag, - InboundType: C.TypeTun, - IPVersion: ipVersion, - Network: network, - Source: source, - Destination: destination, - InboundOptions: t.inboundOptions, + Inbound: t.tag, + InboundType: C.TypeTun, + IPVersion: ipVersion, + Network: network, + Source: source, + Destination: destination, }, routeContext, timeout, true) if err != nil { switch { @@ -569,8 +526,7 @@ func (t *autoRedirectHandler) NewConnectionEx(ctx context.Context, conn net.Conn metadata.InboundType = C.TypeTun metadata.Source = source metadata.Destination = destination - //nolint:staticcheck - metadata.InboundOptions = t.inboundOptions + t.logger.InfoContext(ctx, "inbound redirect connection from ", metadata.Source) t.logger.InfoContext(ctx, "inbound connection to ", metadata.Destination) t.router.RouteConnectionEx(ctx, conn, metadata, onClose) diff --git a/protocol/vless/inbound.go b/protocol/vless/inbound.go index 1df7cb01f..75cd4124c 100644 --- a/protocol/vless/inbound.go +++ b/protocol/vless/inbound.go @@ -217,7 +217,6 @@ func (h *inboundTransportHandler) NewConnectionEx(ctx context.Context, conn net. //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions h.logger.InfoContext(ctx, "inbound connection from ", metadata.Source) (*Inbound)(h).NewConnectionEx(ctx, conn, metadata, onClose) } diff --git a/protocol/vmess/inbound.go b/protocol/vmess/inbound.go index 059d4775b..4e9c763c9 100644 --- a/protocol/vmess/inbound.go +++ b/protocol/vmess/inbound.go @@ -223,7 +223,6 @@ func (h *inboundTransportHandler) NewConnectionEx(ctx context.Context, conn net. //nolint:staticcheck metadata.InboundDetour = h.listener.ListenOptions().Detour //nolint:staticcheck - metadata.InboundOptions = h.listener.ListenOptions().InboundOptions h.logger.InfoContext(ctx, "inbound connection from ", metadata.Source) (*Inbound)(h).NewConnectionEx(ctx, conn, metadata, onClose) } diff --git a/protocol/wireguard/outbound.go b/protocol/wireguard/outbound.go deleted file mode 100644 index 5b08c6a7a..000000000 --- a/protocol/wireguard/outbound.go +++ /dev/null @@ -1,176 +0,0 @@ -package wireguard - -import ( - "context" - "net" - "net/netip" - "time" - - "github.com/sagernet/sing-box/adapter" - "github.com/sagernet/sing-box/adapter/outbound" - "github.com/sagernet/sing-box/common/dialer" - C "github.com/sagernet/sing-box/constant" - "github.com/sagernet/sing-box/experimental/deprecated" - "github.com/sagernet/sing-box/log" - "github.com/sagernet/sing-box/option" - "github.com/sagernet/sing-box/transport/wireguard" - tun "github.com/sagernet/sing-tun" - "github.com/sagernet/sing/common" - E "github.com/sagernet/sing/common/exceptions" - "github.com/sagernet/sing/common/logger" - M "github.com/sagernet/sing/common/metadata" - N "github.com/sagernet/sing/common/network" - "github.com/sagernet/sing/service" -) - -var _ adapter.OutboundWithPreferredRoutes = (*Outbound)(nil) - -func RegisterOutbound(registry *outbound.Registry) { - outbound.Register[option.LegacyWireGuardOutboundOptions](registry, C.TypeWireGuard, NewOutbound) -} - -type Outbound struct { - outbound.Adapter - ctx context.Context - dnsRouter adapter.DNSRouter - logger logger.ContextLogger - localAddresses []netip.Prefix - endpoint *wireguard.Endpoint -} - -func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.LegacyWireGuardOutboundOptions) (adapter.Outbound, error) { - deprecated.Report(ctx, deprecated.OptionWireGuardOutbound) - if options.GSO { - deprecated.Report(ctx, deprecated.OptionWireGuardGSO) - } - outbound := &Outbound{ - Adapter: outbound.NewAdapterWithDialerOptions(C.TypeWireGuard, tag, []string{N.NetworkTCP, N.NetworkUDP, N.NetworkICMP}, options.DialerOptions), - ctx: ctx, - dnsRouter: service.FromContext[adapter.DNSRouter](ctx), - logger: logger, - localAddresses: options.LocalAddress, - } - if options.Detour != "" && options.GSO { - return nil, E.New("gso is conflict with detour") - } - outboundDialer, err := dialer.NewWithOptions(dialer.Options{ - Context: ctx, - Options: options.DialerOptions, - RemoteIsDomain: options.ServerIsDomain() || common.Any(options.Peers, func(it option.LegacyWireGuardPeer) bool { - return it.ServerIsDomain() - }), - ResolverOnDetour: true, - }) - if err != nil { - return nil, err - } - peers := common.Map(options.Peers, func(it option.LegacyWireGuardPeer) wireguard.PeerOptions { - return wireguard.PeerOptions{ - Endpoint: it.ServerOptions.Build(), - PublicKey: it.PublicKey, - PreSharedKey: it.PreSharedKey, - AllowedIPs: it.AllowedIPs, - // PersistentKeepaliveInterval: time.Duration(it.PersistentKeepaliveInterval), - Reserved: it.Reserved, - } - }) - if len(peers) == 0 { - peers = []wireguard.PeerOptions{{ - Endpoint: options.ServerOptions.Build(), - PublicKey: options.PeerPublicKey, - PreSharedKey: options.PreSharedKey, - AllowedIPs: []netip.Prefix{netip.PrefixFrom(netip.IPv4Unspecified(), 0), netip.PrefixFrom(netip.IPv6Unspecified(), 0)}, - Reserved: options.Reserved, - }} - } - wgEndpoint, err := wireguard.NewEndpoint(wireguard.EndpointOptions{ - Context: ctx, - Logger: logger, - System: options.SystemInterface, - Dialer: outboundDialer, - CreateDialer: func(interfaceName string) N.Dialer { - return common.Must1(dialer.NewDefault(ctx, option.DialerOptions{ - BindInterface: interfaceName, - })) - }, - Name: options.InterfaceName, - MTU: options.MTU, - Address: options.LocalAddress, - PrivateKey: options.PrivateKey, - ResolvePeer: func(domain string) (netip.Addr, error) { - endpointAddresses, lookupErr := outbound.dnsRouter.Lookup(ctx, domain, outboundDialer.(dialer.ResolveDialer).QueryOptions()) - if lookupErr != nil { - return netip.Addr{}, lookupErr - } - return endpointAddresses[0], nil - }, - Peers: peers, - Workers: options.Workers, - }) - if err != nil { - return nil, err - } - outbound.endpoint = wgEndpoint - return outbound, nil -} - -func (o *Outbound) Start(stage adapter.StartStage) error { - switch stage { - case adapter.StartStateStart: - return o.endpoint.Start(false) - case adapter.StartStatePostStart: - return o.endpoint.Start(true) - } - return nil -} - -func (o *Outbound) Close() error { - return o.endpoint.Close() -} - -func (o *Outbound) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) { - switch network { - case N.NetworkTCP: - o.logger.InfoContext(ctx, "outbound connection to ", destination) - case N.NetworkUDP: - o.logger.InfoContext(ctx, "outbound packet connection to ", destination) - } - if destination.IsFqdn() { - destinationAddresses, err := o.dnsRouter.Lookup(ctx, destination.Fqdn, adapter.DNSQueryOptions{}) - if err != nil { - return nil, err - } - return N.DialSerial(ctx, o.endpoint, network, destination, destinationAddresses) - } else if !destination.Addr.IsValid() { - return nil, E.New("invalid destination: ", destination) - } - return o.endpoint.DialContext(ctx, network, destination) -} - -func (o *Outbound) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) { - o.logger.InfoContext(ctx, "outbound packet connection to ", destination) - if destination.IsFqdn() { - destinationAddresses, err := o.dnsRouter.Lookup(ctx, destination.Fqdn, adapter.DNSQueryOptions{}) - if err != nil { - return nil, err - } - packetConn, _, err := N.ListenSerial(ctx, o.endpoint, destination, destinationAddresses) - if err != nil { - return nil, err - } - return packetConn, err - } - return o.endpoint.ListenPacket(ctx, destination) -} - -func (o *Outbound) PreferredDomain(domain string) bool { - return false -} - -func (o *Outbound) PreferredAddress(address netip.Addr) bool { - return o.endpoint.Lookup(address) != nil -} - -func (o *Outbound) NewDirectRouteConnection(metadata adapter.InboundContext, routeContext tun.DirectRouteContext, timeout time.Duration) (tun.DirectRouteDestination, error) { - return o.endpoint.NewDirectRouteConnection(metadata, routeContext, timeout) -} diff --git a/route/route.go b/route/route.go index 240d0343a..cdd7ba250 100644 --- a/route/route.go +++ b/route/route.go @@ -12,7 +12,6 @@ import ( "github.com/sagernet/sing-box/common/process" "github.com/sagernet/sing-box/common/sniff" C "github.com/sagernet/sing-box/constant" - "github.com/sagernet/sing-box/option" R "github.com/sagernet/sing-box/route/rule" "github.com/sagernet/sing-mux" "github.com/sagernet/sing-tun" @@ -468,37 +467,6 @@ func (r *Router) matchRule( metadata.IPVersion = 6 } - //nolint:staticcheck - if metadata.InboundOptions != common.DefaultValue[option.InboundOptions]() { - if !preMatch && metadata.InboundOptions.SniffEnabled { - newBuffer, newPackerBuffers, newErr := r.actionSniff(ctx, metadata, &R.RuleActionSniff{ - OverrideDestination: metadata.InboundOptions.SniffOverrideDestination, - Timeout: time.Duration(metadata.InboundOptions.SniffTimeout), - }, inputConn, inputPacketConn, nil, nil) - if newBuffer != nil { - buffers = []*buf.Buffer{newBuffer} - } else if len(newPackerBuffers) > 0 { - packetBuffers = newPackerBuffers - } - if newErr != nil { - fatalErr = newErr - return - } - } - if C.DomainStrategy(metadata.InboundOptions.DomainStrategy) != C.DomainStrategyAsIS { - fatalErr = r.actionResolve(ctx, metadata, &R.RuleActionResolve{ - Strategy: C.DomainStrategy(metadata.InboundOptions.DomainStrategy), - }) - if fatalErr != nil { - return - } - } - if metadata.InboundOptions.UDPDisableDomainUnmapping { - metadata.UDPDisableDomainUnmapping = true - } - metadata.InboundOptions = option.InboundOptions{} - } - match: for currentRuleIndex, currentRule := range r.rules { metadata.ResetRuleCache() diff --git a/route/rule/rule_default.go b/route/rule/rule_default.go index 66a6e5a72..202fb3b36 100644 --- a/route/rule/rule_default.go +++ b/route/rule/rule_default.go @@ -5,7 +5,6 @@ import ( "github.com/sagernet/sing-box/adapter" C "github.com/sagernet/sing-box/constant" - "github.com/sagernet/sing-box/experimental/deprecated" "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common" @@ -267,14 +266,13 @@ func NewDefaultRule(ctx context.Context, logger log.ContextLogger, options optio rule.allItems = append(rule.allItems, item) } if len(options.RuleSet) > 0 { + //nolint:staticcheck + if options.Deprecated_RulesetIPCIDRMatchSource { + return nil, E.New("rule_set_ipcidr_match_source is deprecated in sing-box 1.10.0 and removed in sing-box 1.11.0") + } var matchSource bool if options.RuleSetIPCIDRMatchSource { matchSource = true - } else - //nolint:staticcheck - if options.Deprecated_RulesetIPCIDRMatchSource { - matchSource = true - deprecated.Report(ctx, deprecated.OptionBadMatchSource) } item := NewRuleSetItem(router, options.RuleSet, matchSource, false) rule.items = append(rule.items, item) diff --git a/route/rule/rule_dns.go b/route/rule/rule_dns.go index d9570cae9..9235dd6fd 100644 --- a/route/rule/rule_dns.go +++ b/route/rule/rule_dns.go @@ -5,7 +5,6 @@ import ( "github.com/sagernet/sing-box/adapter" C "github.com/sagernet/sing-box/constant" - "github.com/sagernet/sing-box/experimental/deprecated" "github.com/sagernet/sing-box/log" "github.com/sagernet/sing-box/option" "github.com/sagernet/sing/common" @@ -263,14 +262,13 @@ func NewDefaultDNSRule(ctx context.Context, logger log.ContextLogger, options op rule.allItems = append(rule.allItems, item) } if len(options.RuleSet) > 0 { + //nolint:staticcheck + if options.Deprecated_RulesetIPCIDRMatchSource { + return nil, E.New("rule_set_ipcidr_match_source is deprecated in sing-box 1.10.0 and removed in sing-box 1.11.0") + } var matchSource bool if options.RuleSetIPCIDRMatchSource { matchSource = true - } else - //nolint:staticcheck - if options.Deprecated_RulesetIPCIDRMatchSource { - matchSource = true - deprecated.Report(ctx, deprecated.OptionBadMatchSource) } item := NewRuleSetItem(router, options.RuleSet, matchSource, options.RuleSetIPCIDRAcceptEmpty) rule.items = append(rule.items, item) diff --git a/test/domain_inbound_test.go b/test/domain_inbound_test.go index 605740d4e..023545643 100644 --- a/test/domain_inbound_test.go +++ b/test/domain_inbound_test.go @@ -32,9 +32,6 @@ func TestTUICDomainUDP(t *testing.T) { ListenOptions: option.ListenOptions{ Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())), ListenPort: serverPort, - InboundOptions: option.InboundOptions{ - DomainStrategy: option.DomainStrategy(C.DomainStrategyIPv6Only), - }, }, Users: []option.TUICUser{{ UUID: uuid.Nil.String(), diff --git a/test/inbound_detour_test.go b/test/inbound_detour_test.go index 93c283aac..f4043895c 100644 --- a/test/inbound_detour_test.go +++ b/test/inbound_detour_test.go @@ -32,9 +32,7 @@ func TestChainedInbound(t *testing.T) { ListenOptions: option.ListenOptions{ Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())), ListenPort: serverPort, - InboundOptions: option.InboundOptions{ - Detour: "detour", - }, + Detour: "detour", }, Method: method, Password: password, diff --git a/test/shadowtls_test.go b/test/shadowtls_test.go index 28cd1da01..6c4b71d44 100644 --- a/test/shadowtls_test.go +++ b/test/shadowtls_test.go @@ -75,10 +75,7 @@ func testShadowTLS(t *testing.T, version int, password string, utlsEanbled bool, ListenOptions: option.ListenOptions{ Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())), ListenPort: serverPort, - - InboundOptions: option.InboundOptions{ - Detour: "detour", - }, + Detour: "detour", }, Handshake: option.ShadowTLSHandshakeOptions{ ServerOptions: option.ServerOptions{ @@ -343,9 +340,7 @@ func TestShadowTLSInbound(t *testing.T) { ListenOptions: option.ListenOptions{ Listen: common.Ptr(badoption.Addr(netip.IPv4Unspecified())), ListenPort: serverPort, - InboundOptions: option.InboundOptions{ - Detour: "detour", - }, + Detour: "detour", }, Handshake: option.ShadowTLSHandshakeOptions{ ServerOptions: option.ServerOptions{