mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
Split directRay from ray.go
This commit is contained in:
parent
e79f4450b4
commit
a03eaa0316
37
transport/ray/direct.go
Normal file
37
transport/ray/direct.go
Normal file
@ -0,0 +1,37 @@
|
||||
package ray
|
||||
|
||||
import (
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
)
|
||||
|
||||
const (
|
||||
bufferSize = 16
|
||||
)
|
||||
|
||||
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
|
||||
}
|
@ -4,17 +4,6 @@ import (
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
)
|
||||
|
||||
const (
|
||||
bufferSize = 16
|
||||
)
|
||||
|
||||
func NewRay() Ray {
|
||||
return &directRay{
|
||||
Input: make(chan *alloc.Buffer, bufferSize),
|
||||
Output: make(chan *alloc.Buffer, bufferSize),
|
||||
}
|
||||
}
|
||||
|
||||
// OutboundRay is a transport interface for outbound connections.
|
||||
type OutboundRay interface {
|
||||
// OutboundInput provides a stream for the input of the outbound connection.
|
||||
@ -45,24 +34,3 @@ type Ray interface {
|
||||
InboundRay
|
||||
OutboundRay
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user