router.go 787 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package routing
  2. import (
  3. "context"
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/features"
  6. )
  7. // Router is a feature to choose an outbound tag for the given request.
  8. type Router interface {
  9. features.Feature
  10. // PickRoute returns a tag of an OutboundHandler based on the given context.
  11. PickRoute(ctx context.Context) (string, error)
  12. }
  13. // RouterType return the type of Router interface. Can be used to implement common.HasType.
  14. func RouterType() interface{} {
  15. return (*Router)(nil)
  16. }
  17. type DefaultRouter struct{}
  18. func (DefaultRouter) Type() interface{} {
  19. return RouterType()
  20. }
  21. func (DefaultRouter) PickRoute(ctx context.Context) (string, error) {
  22. return "", common.ErrNoClue
  23. }
  24. func (DefaultRouter) Start() error {
  25. return nil
  26. }
  27. func (DefaultRouter) Close() error {
  28. return nil
  29. }