Browse Source

finish UnixInboundHandler

pull/1019/head
Shelikhoo 7 years ago
parent
commit
3e05a3529a
No known key found for this signature in database
GPG Key ID: 7791BDB0709ABD21
  1. 28
      app/proxyman/inbound/unix.go

28
app/proxyman/inbound/unix.go

@ -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 {

Loading…
Cancel
Save