mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
refactor io package
This commit is contained in:
@@ -5,7 +5,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"v2ray.com/core/app/dispatcher"
|
||||
v2io "v2ray.com/core/common/io"
|
||||
"v2ray.com/core/common/buf"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/proxy"
|
||||
)
|
||||
@@ -49,19 +49,19 @@ func (v *InboundConnectionHandler) Communicate(destination v2net.Destination) er
|
||||
writeFinish.Lock()
|
||||
|
||||
go func() {
|
||||
v2reader := v2io.NewAdaptiveReader(v.ConnInput)
|
||||
v2reader := buf.NewReader(v.ConnInput)
|
||||
defer v2reader.Release()
|
||||
|
||||
v2io.Pipe(v2reader, input)
|
||||
buf.Pipe(v2reader, input)
|
||||
input.Close()
|
||||
readFinish.Unlock()
|
||||
}()
|
||||
|
||||
go func() {
|
||||
v2writer := v2io.NewAdaptiveWriter(v.ConnOutput)
|
||||
v2writer := buf.NewWriter(v.ConnOutput)
|
||||
defer v2writer.Release()
|
||||
|
||||
v2io.Pipe(output, v2writer)
|
||||
buf.Pipe(output, v2writer)
|
||||
output.Release()
|
||||
writeFinish.Unlock()
|
||||
}()
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
"v2ray.com/core/app"
|
||||
"v2ray.com/core/common/buf"
|
||||
v2io "v2ray.com/core/common/io"
|
||||
v2net "v2ray.com/core/common/net"
|
||||
"v2ray.com/core/proxy"
|
||||
"v2ray.com/core/transport/ray"
|
||||
@@ -33,20 +32,20 @@ func (v *OutboundConnectionHandler) Dispatch(destination v2net.Destination, payl
|
||||
writeFinish.Lock()
|
||||
|
||||
go func() {
|
||||
v2writer := v2io.NewAdaptiveWriter(v.ConnOutput)
|
||||
v2writer := buf.NewWriter(v.ConnOutput)
|
||||
defer v2writer.Release()
|
||||
|
||||
v2io.Pipe(input, v2writer)
|
||||
buf.Pipe(input, v2writer)
|
||||
writeFinish.Unlock()
|
||||
input.Release()
|
||||
}()
|
||||
|
||||
writeFinish.Lock()
|
||||
|
||||
v2reader := v2io.NewAdaptiveReader(v.ConnInput)
|
||||
v2reader := buf.NewReader(v.ConnInput)
|
||||
defer v2reader.Release()
|
||||
|
||||
v2io.Pipe(v2reader, output)
|
||||
buf.Pipe(v2reader, output)
|
||||
output.Close()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user