@@ -10,6 +10,7 @@ import (
10
10
v2io "github.com/v2ray/v2ray-core/io"
11
11
vmessio "github.com/v2ray/v2ray-core/io/vmess"
12
12
"github.com/v2ray/v2ray-core/log"
13
+ v2net "github.com/v2ray/v2ray-core/net"
13
14
)
14
15
15
16
type VMessInboundHandler struct {
@@ -92,31 +93,14 @@ func (handler *VMessInboundHandler) HandleConnection(connection net.Conn) error
92
93
}
93
94
94
95
func (handler * VMessInboundHandler ) dumpInput (reader io.Reader , input chan <- []byte , finish chan <- bool ) {
95
- for {
96
- buffer := make ([]byte , BufferSize )
97
- nBytes , err := reader .Read (buffer )
98
- log .Debug ("VMessInbound: Reading %d bytes with error %v" , nBytes , err )
99
- if err == io .EOF {
100
- close (input )
101
- log .Debug ("VMessInbound finishing input." )
102
- finish <- true
103
- break
104
- }
105
- input <- buffer [:nBytes ]
106
- }
96
+ v2net .ReaderToChan (input , reader )
97
+ close (input )
98
+ finish <- true
107
99
}
108
100
109
101
func (handler * VMessInboundHandler ) dumpOutput (writer io.Writer , output <- chan []byte , finish chan <- bool ) {
110
- for {
111
- buffer , open := <- output
112
- if ! open {
113
- finish <- true
114
- log .Debug ("VMessInbound finishing output." )
115
- break
116
- }
117
- nBytes , err := writer .Write (buffer )
118
- log .Debug ("VmessInbound: Wrote %d bytes with error %v" , nBytes , err )
119
- }
102
+ v2net .ChanToWriter (writer , output )
103
+ finish <- true
120
104
}
121
105
122
106
func (handler * VMessInboundHandler ) waitForFinish (finish <- chan bool ) {
0 commit comments