ray.go 1.4 KB

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