Skip to content

Commit

Permalink
fix(listener/tproxy): possilly using released buffer in tproxy
Browse files Browse the repository at this point in the history
  • Loading branch information
5aaee9 committed May 21, 2024
1 parent 43bdc76 commit 0c47e73
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions listener/tproxy/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,12 @@ func listenLocalConn(rAddr, lAddr net.Addr, tunnel C.Tunnel) (*net.UDPConn, erro
buf := pool.Get(pool.UDPBufferSize)
br, err := lc.Read(buf)
if err != nil {
pool.Put(buf)
if errors.Is(err, net.ErrClosed) {
log.Debugln("TProxy local conn listener exit.. rAddr=%s lAddr=%s", rAddr.String(), lAddr.String())
return
if !errors.Is(err, net.ErrClosed) {
log.Debugln("TProxy local conn Read err=%v", err)
}
log.Debugln("TProxy local conn listener exit.. rAddr=%s lAddr=%s", rAddr.String(), lAddr.String())
pool.Put(buf)
return
}
// since following localPackets are pass through this socket which listen rAddr
// I choose current listener as packet's packet conn
Expand Down

0 comments on commit 0c47e73

Please sign in to comment.