inbound.go 979 B

123456789101112131415161718192021222324252627282930313233343536
  1. package inbound
  2. import (
  3. "context"
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/common/net"
  6. "v2ray.com/core/features"
  7. )
  8. // Handler is the interface for handlers that process inbound connections.
  9. type Handler interface {
  10. common.Runnable
  11. // The tag of this handler.
  12. Tag() string
  13. // Deprecated. Do not use in new code.
  14. GetRandomInboundProxy() (interface{}, net.Port, int)
  15. }
  16. // Manager is a feature that manages InboundHandlers.
  17. type Manager interface {
  18. features.Feature
  19. // GetHandlers returns an InboundHandler for the given tag.
  20. GetHandler(ctx context.Context, tag string) (Handler, error)
  21. // AddHandler adds the given handler into this Manager.
  22. AddHandler(ctx context.Context, handler Handler) error
  23. // RemoveHandler removes a handler from Manager.
  24. RemoveHandler(ctx context.Context, tag string) error
  25. }
  26. // ManagerType returns the type of Manager interface. Can be used for implementing common.HasType.
  27. func ManagerType() interface{} {
  28. return (*Manager)(nil)
  29. }