ray.go 1.3 KB

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