ray.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. ForceClose()
  32. }
  33. type OutputStream interface {
  34. buf.Writer
  35. Close()
  36. }