Skip to content

Commit

Permalink
Dokodemo TPROXY: Move "defer pw.Close()" into "responseDone()"
Browse files Browse the repository at this point in the history
Fixes #4194
  • Loading branch information
RPRX authored Dec 26, 2024
1 parent 42aea01 commit 2782f13
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion proxy/dokodemo/dokodemo.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st
return err
}
writer = NewPacketWriter(pConn, &dest, mark, back)
defer writer.(*PacketWriter).Close()
/*
sockopt := &internet.SocketConfig{
Tproxy: internet.SocketConfig_TProxy,
Expand Down Expand Up @@ -219,6 +218,10 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st
responseDone := func() error {
defer timer.SetTimeout(plcy.Timeouts.UplinkOnly)

if pw, ok := writer.(*PacketWriter); ok {
defer pw.Close()
}

if err := buf.Copy(link.Reader, writer, buf.UpdateActivity(timer)); err != nil {
return errors.New("failed to transport response").Base(err)
}
Expand Down

0 comments on commit 2782f13

Please sign in to comment.