inbound.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package inbound
  2. import (
  3. "context"
  4. "github.com/xtls/xray-core/common"
  5. "github.com/xtls/xray-core/common/serial"
  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. // Returns the active receiver settings.
  16. ReceiverSettings() *serial.TypedMessage
  17. // Returns the active proxy settings.
  18. ProxySettings() *serial.TypedMessage
  19. }
  20. // Manager is a feature that manages InboundHandlers.
  21. //
  22. // xray:api:stable
  23. type Manager interface {
  24. features.Feature
  25. // GetHandler returns an InboundHandler for the given tag.
  26. GetHandler(ctx context.Context, tag string) (Handler, error)
  27. // AddHandler adds the given handler into this Manager.
  28. AddHandler(ctx context.Context, handler Handler) error
  29. // RemoveHandler removes a handler from Manager.
  30. RemoveHandler(ctx context.Context, tag string) error
  31. // ListHandlers returns a list of inbound.Handler.
  32. ListHandlers(ctx context.Context) []Handler
  33. }
  34. // ManagerType returns the type of Manager interface. Can be used for implementing common.HasType.
  35. //
  36. // xray:api:stable
  37. func ManagerType() interface{} {
  38. return (*Manager)(nil)
  39. }