ray.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package ray
  2. import (
  3. "v2ray.com/core/common"
  4. "v2ray.com/core/common/buf"
  5. )
  6. // OutboundRay is a transport interface for outbound connections.
  7. type OutboundRay interface {
  8. // OutboundInput provides a stream for the input of the outbound connection.
  9. // The outbound connection shall write all the input until it is closed.
  10. OutboundInput() InputStream
  11. // OutboundOutput provides a stream to retrieve the response from the
  12. // outbound connection. The outbound connection shall close the channel
  13. // after all responses are receivced and put into the channel.
  14. OutboundOutput() OutputStream
  15. }
  16. // InboundRay is a transport interface for inbound connections.
  17. type InboundRay interface {
  18. // InboundInput provides a stream to retrieve the request from client.
  19. // The inbound connection shall close the channel after the entire request
  20. // is received and put into the channel.
  21. InboundInput() OutputStream
  22. // InboudBound provides a stream of data for the inbound connection to write
  23. // as response. The inbound connection shall write all the data from the
  24. // channel until it is closed.
  25. InboundOutput() InputStream
  26. }
  27. // Ray is an internal tranport channel between inbound and outbound connection.
  28. type Ray interface {
  29. InboundRay
  30. OutboundRay
  31. }
  32. type RayStream interface {
  33. common.Closable
  34. CloseError()
  35. }
  36. type InputStream interface {
  37. buf.Reader
  38. buf.TimeoutReader
  39. RayStream
  40. Peek(*buf.Buffer)
  41. }
  42. type OutputStream interface {
  43. buf.Writer
  44. RayStream
  45. }