2015-09-12 16:11:54 -04:00
|
|
|
package core
|
|
|
|
|
2015-10-08 08:46:18 -04:00
|
|
|
import (
|
|
|
|
"github.com/v2ray/v2ray-core/common/alloc"
|
|
|
|
)
|
|
|
|
|
2015-09-14 07:51:30 -04:00
|
|
|
const (
|
2015-09-14 12:19:17 -04:00
|
|
|
bufferSize = 16
|
2015-09-14 07:51:30 -04:00
|
|
|
)
|
|
|
|
|
2015-09-22 08:45:03 -04:00
|
|
|
// Ray is an internal tranport channel bewteen inbound and outbound connection.
|
2015-09-12 16:11:54 -04:00
|
|
|
type Ray struct {
|
2015-10-08 08:46:18 -04:00
|
|
|
Input chan *alloc.Buffer
|
|
|
|
Output chan *alloc.Buffer
|
2015-09-12 16:11:54 -04:00
|
|
|
}
|
|
|
|
|
2015-09-22 08:45:03 -04:00
|
|
|
func NewRay() *Ray {
|
|
|
|
return &Ray{
|
2015-10-08 08:46:18 -04:00
|
|
|
Input: make(chan *alloc.Buffer, bufferSize),
|
|
|
|
Output: make(chan *alloc.Buffer, bufferSize),
|
2015-09-16 11:07:05 -04:00
|
|
|
}
|
2015-09-12 16:11:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type OutboundRay interface {
|
2015-10-08 08:46:18 -04:00
|
|
|
OutboundInput() <-chan *alloc.Buffer
|
|
|
|
OutboundOutput() chan<- *alloc.Buffer
|
2015-09-12 16:11:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
type InboundRay interface {
|
2015-10-08 08:46:18 -04:00
|
|
|
InboundInput() chan<- *alloc.Buffer
|
|
|
|
InboundOutput() <-chan *alloc.Buffer
|
2015-09-12 16:11:54 -04:00
|
|
|
}
|
|
|
|
|
2015-10-08 08:46:18 -04:00
|
|
|
func (ray *Ray) OutboundInput() <-chan *alloc.Buffer {
|
2015-09-12 16:11:54 -04:00
|
|
|
return ray.Input
|
|
|
|
}
|
|
|
|
|
2015-10-08 08:46:18 -04:00
|
|
|
func (ray *Ray) OutboundOutput() chan<- *alloc.Buffer {
|
2015-09-12 16:11:54 -04:00
|
|
|
return ray.Output
|
|
|
|
}
|
|
|
|
|
2015-10-08 08:46:18 -04:00
|
|
|
func (ray *Ray) InboundInput() chan<- *alloc.Buffer {
|
2015-09-12 16:11:54 -04:00
|
|
|
return ray.Input
|
|
|
|
}
|
|
|
|
|
2015-10-08 08:46:18 -04:00
|
|
|
func (ray *Ray) InboundOutput() <-chan *alloc.Buffer {
|
2015-09-12 16:11:54 -04:00
|
|
|
return ray.Output
|
|
|
|
}
|