quic_stub.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //go:build !with_quic
  2. package include
  3. import (
  4. "context"
  5. "github.com/sagernet/sing-box/adapter"
  6. "github.com/sagernet/sing-box/adapter/outbound"
  7. "github.com/sagernet/sing-box/common/tls"
  8. C "github.com/sagernet/sing-box/constant"
  9. "github.com/sagernet/sing-box/log"
  10. "github.com/sagernet/sing-box/option"
  11. "github.com/sagernet/sing-box/transport/v2ray"
  12. "github.com/sagernet/sing-dns"
  13. "github.com/sagernet/sing/common/logger"
  14. M "github.com/sagernet/sing/common/metadata"
  15. N "github.com/sagernet/sing/common/network"
  16. )
  17. func init() {
  18. dns.RegisterTransport([]string{"quic", "h3"}, func(options dns.TransportOptions) (dns.Transport, error) {
  19. return nil, C.ErrQUICNotIncluded
  20. })
  21. v2ray.RegisterQUICConstructor(
  22. func(ctx context.Context, logger logger.ContextLogger, options option.V2RayQUICOptions, tlsConfig tls.ServerConfig, handler adapter.V2RayServerTransportHandler) (adapter.V2RayServerTransport, error) {
  23. return nil, C.ErrQUICNotIncluded
  24. },
  25. func(ctx context.Context, dialer N.Dialer, serverAddr M.Socksaddr, options option.V2RayQUICOptions, tlsConfig tls.Config) (adapter.V2RayClientTransport, error) {
  26. return nil, C.ErrQUICNotIncluded
  27. },
  28. )
  29. }
  30. func registerQUICOutbounds(registry *outbound.Registry) {
  31. outbound.Register[option.HysteriaOutboundOptions](registry, C.TypeHysteria, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.HysteriaOutboundOptions) (adapter.Outbound, error) {
  32. return nil, C.ErrQUICNotIncluded
  33. })
  34. outbound.Register[option.TUICOutboundOptions](registry, C.TypeTUIC, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.TUICOutboundOptions) (adapter.Outbound, error) {
  35. return nil, C.ErrQUICNotIncluded
  36. })
  37. outbound.Register[option.Hysteria2OutboundOptions](registry, C.TypeHysteria2, func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.Hysteria2OutboundOptions) (adapter.Outbound, error) {
  38. return nil, C.ErrQUICNotIncluded
  39. })
  40. }