ray.go 1.3 KB

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