dispatcher.go 759 B

123456789101112131415161718192021222324252627
  1. package routing
  2. import (
  3. "context"
  4. "github.com/xtls/xray-core/common/net"
  5. "github.com/xtls/xray-core/features"
  6. "github.com/xtls/xray-core/transport"
  7. )
  8. // Dispatcher is a feature that dispatches inbound requests to outbound handlers based on rules.
  9. // Dispatcher is required to be registered in a Xray instance to make Xray function properly.
  10. //
  11. // xray:api:stable
  12. type Dispatcher interface {
  13. features.Feature
  14. // Dispatch returns a Ray for transporting data for the given request.
  15. Dispatch(ctx context.Context, dest net.Destination) (*transport.Link, error)
  16. }
  17. // DispatcherType returns the type of Dispatcher interface. Can be used to implement common.HasType.
  18. //
  19. // xray:api:stable
  20. func DispatcherType() interface{} {
  21. return (*Dispatcher)(nil)
  22. }