1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

finish UnixInboundHandler

This commit is contained in:
Shelikhoo 2018-03-18 22:08:03 +08:00
parent 3b1f0ae300
commit 3e05a3529a
No known key found for this signature in database
GPG Key ID: 7791BDB0709ABD21

View File

@ -26,7 +26,33 @@ func (uih *UnixInboundHandler) Start() {
if err != nil {
newError(err).AtError().WriteToLog()
}
err = uih.listenerHolder.LowerUP()
if err != nil {
newError(err).AtError().WriteToLog()
}
nchan := make(chan net.Conn, 2)
err = uih.listenerHolder.UP(nchan, false)
if err != nil {
newError(err).AtError().WriteToLog()
}
go uih.progressTraffic(nchan)
return
}
func (uih *UnixInboundHandler) progressTraffic(rece <-chan net.Conn) {
for {
conn := <-rece
go func(conn net.Conn) {
ctx, cancel := context.WithCancel(uih.ctx)
if len(uih.tag) > 0 {
ctx = proxy.ContextWithInboundTag(ctx, uih.tag)
}
if err := uih.proxy.Process(ctx, net.Network_TCP, conn, uih.mux); err != nil {
newError("connection ends").Base(err).WriteToLog()
}
cancel()
conn.Close()
}(conn)
}
}
func (uih *UnixInboundHandler) Close() {
if uih.listenerHolder != nil {