direct.go 715 B

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