direct.go 649 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package ray
  2. import (
  3. "github.com/v2ray/v2ray-core/common/alloc"
  4. )
  5. const (
  6. bufferSize = 16
  7. )
  8. func NewRay() Ray {
  9. return &directRay{
  10. Input: make(chan *alloc.Buffer, bufferSize),
  11. Output: make(chan *alloc.Buffer, bufferSize),
  12. }
  13. }
  14. type directRay struct {
  15. Input chan *alloc.Buffer
  16. Output chan *alloc.Buffer
  17. }
  18. func (ray *directRay) OutboundInput() <-chan *alloc.Buffer {
  19. return ray.Input
  20. }
  21. func (ray *directRay) OutboundOutput() chan<- *alloc.Buffer {
  22. return ray.Output
  23. }
  24. func (ray *directRay) InboundInput() chan<- *alloc.Buffer {
  25. return ray.Input
  26. }
  27. func (ray *directRay) InboundOutput() <-chan *alloc.Buffer {
  28. return ray.Output
  29. }