completely remove allow passive connection

This commit is contained in:
Darien Raymond committed 2017-02-07 17:37:26 +01:00
1 parent c245b4506e
commit d72029211f
8 files changed
+32 -145

No files matched your search

+9 -22
View File
@@ -1,13 +1,11 @@
package ray
import (
"context"
"errors"
"io"
"time"
"context"
"v2ray.com/core/common/buf"
)
@@ -46,29 +44,19 @@ func (v *directRay) InboundOutput() InputStream {
return v.Output
}
func (v *directRay) AddInspector(inspector Inspector) {
if inspector == nil {
return
}
v.Input.inspector.AddInspector(inspector)
v.Output.inspector.AddInspector(inspector)
}
type Stream struct {
buffer chan *buf.Buffer
ctx context.Context
close chan bool
err chan bool
inspector *InspectorChain
buffer chan *buf.Buffer
ctx context.Context
close chan bool
err chan bool
}
func NewStream(ctx context.Context) *Stream {
return &Stream{
ctx: ctx,
buffer: make(chan *buf.Buffer, bufferSize),
close: make(chan bool),
err: make(chan bool),
inspector: &InspectorChain{},
ctx: ctx,
buffer: make(chan *buf.Buffer, bufferSize),
close: make(chan bool),
err: make(chan bool),
}
}
@@ -139,7 +127,6 @@ func (v *Stream) Write(data *buf.Buffer) (err error) {
case <-v.close:
return io.ErrClosedPipe
case v.buffer <- data:
v.inspector.Input(data)
return nil
}
}
-36
View File
@@ -1,36 +0,0 @@
package ray
import (
"sync"
"v2ray.com/core/common/buf"
)
type Inspector interface {
Input(*buf.Buffer)
}
type NoOpInspector struct{}
func (NoOpInspector) Input(*buf.Buffer) {}
type InspectorChain struct {
sync.RWMutex
chain []Inspector
}
func (ic *InspectorChain) AddInspector(inspector Inspector) {
ic.Lock()
defer ic.Unlock()
ic.chain = append(ic.chain, inspector)
}
func (ic *InspectorChain) Input(b *buf.Buffer) {
ic.RLock()
defer ic.RUnlock()
for _, inspector := range ic.chain {
inspector.Input(b)
}
}
-1
View File
@@ -32,7 +32,6 @@ type InboundRay interface {
type Ray interface {
InboundRay
OutboundRay
AddInspector(Inspector)
}
type RayStream interface {