fix(handler/socks5): accumulate UDP traffic metrics into recorder (issue #45)
The SOCKS5 handler recorder only tracked TCP traffic metrics. UDP
associations (CmdUdp) overwrote TCP byte counts with UDP counts, and
UDP tunnels (CmdUDPTun) recorded zero bytes.
Changes:
- udp.go: change UDP stats assignment (=) to accumulation (+=) so the
TCP control connection bytes tracked by Handle() are preserved.
- udp_tun.go: add xstats.Stats{} wrapper around the PacketConn with
deferred accumulation into HandlerRecorderObject, mirroring the
handleUDP pattern.
This commit is contained in:
@@ -97,8 +97,8 @@ func (h *socks5Handler) handleUDP(ctx context.Context, conn net.Conn, network st
|
||||
cc = stats_wrapper.WrapPacketConn(cc, &pStats)
|
||||
|
||||
defer func() {
|
||||
ro.InputBytes = pStats.Get(stats.KindInputBytes)
|
||||
ro.OutputBytes = pStats.Get(stats.KindOutputBytes)
|
||||
ro.InputBytes += pStats.Get(stats.KindInputBytes)
|
||||
ro.OutputBytes += pStats.Get(stats.KindOutputBytes)
|
||||
}()
|
||||
|
||||
clientID := ctxvalue.ClientIDFromContext(ctx)
|
||||
|
||||
Reference in New Issue
Block a user