ray.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. AddInspector(Inspector)
  30. }
  31. type RayStream interface {
  32. Close()
  33. CloseError()
  34. }
  35. type InputStream interface {
  36. buf.Reader
  37. RayStream
  38. ReadTimeout(time.Duration) (*buf.Buffer, error)
  39. }
  40. type OutputStream interface {
  41. buf.Writer
  42. RayStream
  43. }