outbound.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package outbound
  2. import (
  3. "context"
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/common/vio"
  6. "v2ray.com/core/features"
  7. )
  8. // Handler is the interface for handlers that process outbound connections.
  9. type Handler interface {
  10. common.Runnable
  11. Tag() string
  12. Dispatch(ctx context.Context, link *vio.Link)
  13. }
  14. // Manager is a feature that manages outbound.Handlers.
  15. type Manager interface {
  16. features.Feature
  17. // GetHandler returns an outbound.Handler for the given tag.
  18. GetHandler(tag string) Handler
  19. // GetDefaultHandler returns the default outbound.Handler. It is usually the first outbound.Handler specified in the configuration.
  20. GetDefaultHandler() Handler
  21. // AddHandler adds a handler into this outbound.Manager.
  22. AddHandler(ctx context.Context, handler Handler) error
  23. // RemoveHandler removes a handler from outbound.Manager.
  24. RemoveHandler(ctx context.Context, tag string) error
  25. }
  26. // ManagerType returns the type of Manager interface. Can be used to implement common.HasType.
  27. func ManagerType() interface{} {
  28. return (*Manager)(nil)
  29. }