inbound.go 1.1 KB

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