1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-10 06:16:53 -05:00
v2fly/ray.go

49 lines
910 B
Go
Raw Normal View History

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