ray.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package ray
  2. import (
  3. "github.com/v2ray/v2ray-core/common/alloc"
  4. )
  5. // OutboundRay is a transport interface for outbound connections.
  6. type OutboundRay interface {
  7. // OutboundInput provides a stream for the input of the outbound connection.
  8. // The outbound connection shall write all the input until it is closed.
  9. OutboundInput() <-chan *alloc.Buffer
  10. // OutboundOutput provides a stream to retrieve the response from the
  11. // outbound connection. The outbound connection shall close the channel
  12. // after all responses are receivced and put into the channel.
  13. OutboundOutput() chan<- *alloc.Buffer
  14. }
  15. // InboundRay is a transport interface for inbound connections.
  16. type InboundRay interface {
  17. // InboundInput provides a stream to retrieve the request from client.
  18. // The inbound connection shall close the channel after the entire request
  19. // is received and put into the channel.
  20. InboundInput() chan<- *alloc.Buffer
  21. // InboudBound provides a stream of data for the inbound connection to write
  22. // as response. The inbound connection shall write all the data from the
  23. // channel until it is closed.
  24. InboundOutput() <-chan *alloc.Buffer
  25. }
  26. // Ray is an internal tranport channel between inbound and outbound connection.
  27. type Ray interface {
  28. InboundRay
  29. OutboundRay
  30. }