dispatcher.go 778 B

123456789101112131415161718192021222324252627
  1. package routing
  2. import (
  3. "context"
  4. "github.com/v2fly/v2ray-core/v5/common/net"
  5. "github.com/v2fly/v2ray-core/v5/features"
  6. "github.com/v2fly/v2ray-core/v5/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 V2Ray instance to make V2Ray function properly.
  10. //
  11. // v2ray: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. // v2ray:api:stable
  20. func DispatcherType() interface{} {
  21. return (*Dispatcher)(nil)
  22. }