Documentation
¶
Overview ¶
Package conntrack provides a lightweight TCP connection tracker that implements connection.PacketObserver. It counts recently-active TCP flows by watching packet traffic, enabling early drain exit when all connections have closed or gone quiet.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker counts active TCP connections by observing packets via the PacketObserver interface. Safe for concurrent use.
func (*Tracker) ActiveCount ¶
ActiveCount returns the number of tracked TCP connections that carried traffic within the last activeWindow. Flows idle longer than that are excluded: they are either dead without an observed teardown or quiet keepalive connections that a graceful drain should not wait on.
func (*Tracker) OnPacket ¶
func (t *Tracker) OnPacket(info connection.PacketInfo)
OnPacket implements connection.PacketObserver. It inspects TCP flags to track connection lifecycle (SYN opens, FIN/RST closes) and refreshes flow liveness on every observed packet. Both directions of a connection map to one tracked flow via the canonical key, so the SYN-ACK does not create a second entry and each side's FIN is recorded against the same flow.