conntrack

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

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 NewTracker

func NewTracker() *Tracker

NewTracker creates a new TCP connection tracker.

func (*Tracker) ActiveCount

func (t *Tracker) ActiveCount() int

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL