2015-10-14 09:07:13 -04:00
|
|
|
package ray
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/v2ray/v2ray-core/common/alloc"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
bufferSize = 16
|
|
|
|
)
|
|
|
|
|
2015-10-15 07:15:59 -04:00
|
|
|
// NewRay creates a new Ray for direct traffic transport.
|
2015-10-14 09:07:13 -04:00
|
|
|
func NewRay() Ray {
|
|
|
|
return &directRay{
|
|
|
|
Input: make(chan *alloc.Buffer, bufferSize),
|
|
|
|
Output: make(chan *alloc.Buffer, bufferSize),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type directRay struct {
|
|
|
|
Input chan *alloc.Buffer
|
|
|
|
Output chan *alloc.Buffer
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ray *directRay) OutboundInput() <-chan *alloc.Buffer {
|
|
|
|
return ray.Input
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ray *directRay) OutboundOutput() chan<- *alloc.Buffer {
|
|
|
|
return ray.Output
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ray *directRay) InboundInput() chan<- *alloc.Buffer {
|
|
|
|
return ray.Input
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ray *directRay) InboundOutput() <-chan *alloc.Buffer {
|
|
|
|
return ray.Output
|
|
|
|
}
|