Socks inbound: Fix stats for UDP Associate traffic (#7101)

https://github.com/XTLS/Xray-core/pull/7101#pullrequestreview-5452526703

---------

Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>
This commit is contained in:
IvanTopGaming
2026-10-08 09:21:21 +00:00
committed by GitHub
co-authored by 风扇滑翔翼
parent 8989adfd3f
commit 2a14c50775
+9 -1
View File
@@ -170,9 +170,17 @@ func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatche
return errors.New("UDP associate with listen port failed")
}
tempUDPConn.SetTimeout(plcy.Timeouts.ConnectionIdle)
var udpConn stat.Connection = tempUDPConn
if counters, ok := conn.(*stat.CounterConnection); ok {
udpConn = &stat.CounterConnection{
Connection: tempUDPConn,
ReadCounter: counters.ReadCounter,
WriteCounter: counters.WriteCounter,
}
}
errCh := make(chan error, 1)
go func() {
errCh <- s.handleUDPPayload(ctx, tempUDPConn, dispatcher)
errCh <- s.handleUDPPayload(ctx, udpConn, dispatcher)
}()
// Associated TCP keeps the UDP alive
// Close UDP if TCP connection is closed