Introduce Packet to unify TCP and UDP communication

This commit is contained in:
V2Ray committed 2015-09-22 14:45:03 +02:00
1 parent 4320c14efd
commit 4874cd54a4
12 files changed
+124 -41

No files matched your search

+10 -6
View File
@@ -4,13 +4,14 @@ const (
bufferSize = 16
)
// Ray is an internal tranport channel bewteen inbound and outbound connection.
type Ray struct {
Input chan []byte
Output chan []byte
}
func NewRay() Ray {
return Ray{
func NewRay() *Ray {
return &Ray{
Input: make(chan []byte, bufferSize),
Output: make(chan []byte, bufferSize),
}
@@ -26,18 +27,21 @@ type InboundRay interface {
InboundOutput() <-chan []byte
}
func (ray Ray) OutboundInput() <-chan []byte {
func (ray *Ray) OutboundInput() <-chan []byte {
return ray.Input
}
func (ray Ray) OutboundOutput() chan<- []byte {
func (ray *Ray) OutboundOutput() chan<- []byte {
return ray.Output
}
func (ray Ray) InboundInput() chan<- []byte {
func (ray *Ray) InboundInput() chan<- []byte {
return ray.Input
}
func (ray Ray) InboundOutput() <-chan []byte {
func (ray *Ray) InboundOutput() <-chan []byte {
return ray.Output
}
type UDPRay struct {
}