connstats

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: BSD-3-Clause Imports: 8 Imported by: 9

Documentation

Overview

Package connstats maintains statistics about connections flowing through a TUN device (which operate at the IP layer).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Statistics

type Statistics struct {
	// contains filtered or unexported fields
}

Statistics maintains counters for every connection. All methods are safe for concurrent use. The zero value is ready for use.

func NewStatistics added in v1.36.0

func NewStatistics(maxPeriod time.Duration, maxConns int, dump func(start, end time.Time, virtual, physical map[netlogtype.Connection]netlogtype.Counts)) *Statistics

NewStatistics creates a data structure for tracking connection statistics that periodically dumps the virtual and physical connection counts depending on whether the maxPeriod or maxConns is exceeded. The dump function is called from a single goroutine. Shutdown must be called to cleanup resources.

func (*Statistics) Shutdown added in v1.36.0

func (s *Statistics) Shutdown(context.Context) error

Shutdown performs a final flush of statistics. Statistics for any subsequent calls to Update will be dropped. It is safe to call Shutdown concurrently and repeatedly.

func (*Statistics) TestExtract added in v1.36.0

func (s *Statistics) TestExtract() (virtual, physical map[netlogtype.Connection]netlogtype.Counts)

TestExtract synchronously extracts the current network statistics map and resets the counters. This should only be used for testing purposes.

func (*Statistics) UpdateRxPhysical

func (s *Statistics) UpdateRxPhysical(src netip.Addr, dst netip.AddrPort, n int)

UpdateRxPhysical updates the counters for a received wireguard packet. The src is always a Tailscale IP address, representing some remote peer. The dst is a remote IP address and port that corresponds with some physical peer backing the Tailscale IP address.

func (*Statistics) UpdateRxVirtual

func (s *Statistics) UpdateRxVirtual(b []byte)

UpdateRxVirtual updates the counters for a received IP packet. The source and destination of the packet are inverted with respect to the source and destination in netlogtype.Connection.

func (*Statistics) UpdateTxPhysical

func (s *Statistics) UpdateTxPhysical(src netip.Addr, dst netip.AddrPort, n int)

UpdateTxPhysical updates the counters for a transmitted wireguard packet The src is always a Tailscale IP address, representing some remote peer. The dst is a remote IP address and port that corresponds with some physical peer backing the Tailscale IP address.

func (*Statistics) UpdateTxVirtual

func (s *Statistics) UpdateTxVirtual(b []byte)

UpdateTxVirtual updates the counters for a transmitted IP packet The source and destination of the packet directly correspond with the source and destination in netlogtype.Connection.

Jump to

Keyboard shortcuts

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