chore: decrease goroutine used in core tunnel
This commit is contained in:
@ -30,7 +30,7 @@ func (l *Listener) Close() error {
|
||||
return l.listener.Close()
|
||||
}
|
||||
|
||||
func New(addr string, in chan<- C.ConnContext, additions ...inbound.Addition) (*Listener, error) {
|
||||
func New(addr string, tunnel C.Tunnel, additions ...inbound.Addition) (*Listener, error) {
|
||||
if len(additions) == 0 {
|
||||
additions = []inbound.Addition{
|
||||
inbound.WithInName("DEFAULT-REDIR"),
|
||||
@ -55,18 +55,19 @@ func New(addr string, in chan<- C.ConnContext, additions ...inbound.Addition) (*
|
||||
}
|
||||
continue
|
||||
}
|
||||
go handleRedir(c, in, additions...)
|
||||
go handleRedir(c, tunnel, additions...)
|
||||
}
|
||||
}()
|
||||
|
||||
return rl, nil
|
||||
}
|
||||
func handleRedir(conn net.Conn, in chan<- C.ConnContext, additions ...inbound.Addition) {
|
||||
|
||||
func handleRedir(conn net.Conn, tunnel C.Tunnel, additions ...inbound.Addition) {
|
||||
target, err := parserPacket(conn)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
N.TCPKeepAlive(conn)
|
||||
in <- inbound.NewSocket(target, conn, C.REDIR, additions...)
|
||||
tunnel.HandleTCPConn(inbound.NewSocket(target, conn, C.REDIR, additions...))
|
||||
}
|
||||
|
Reference in New Issue
Block a user