mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-13 22:45:13 +00:00
completely remove allow passive connection
This commit is contained in:
8 files changed
+32
-145
No files matched your search
+9
-22
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ type InboundRay interface {
|
||||
type Ray interface {
|
||||
InboundRay
|
||||
OutboundRay
|
||||
AddInspector(Inspector)
|
||||
}
|
||||
|
||||
type RayStream interface {
|
||||
|
||||
Reference in new issue
Block a user