Dokodemo TPROXY: Move "defer pw.Close()" into "responseDone()"

Fixes https://github.com/XTLS/Xray-core/issues/4194
This commit is contained in:
RPRX 2024-12-26 14:17:13 +00:00 committed by GitHub
parent 42aea01fb5
commit 2782f13279
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,
@ -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)
}