netlogtype

package
v1.92.4 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: BSD-3-Clause Imports: 6 Imported by: 21

Documentation

Overview

Package netlogtype defines types for network logging.

Index

Constants

View Source
const (

	// MinMessageJSONSize is the overhead size of Message when it is
	// serialized as JSON assuming that each field is minimally populated.
	// Each [Node] occupies at least [MinNodeJSONSize].
	// Each [ConnectionCounts] occupies at most [MaxConnectionCountsJSONSize].
	MinMessageJSONSize = len(messageJSON)

	// MaxConnectionCountsJSONSize is the maximum size of a ConnectionCounts
	// when it is serialized as JSON, assuming no superfluous whitespace.
	// It does not include the trailing comma that often appears when
	// this object is nested within an array.
	// It assumes that netip.Addr never has IPv6 zones.
	MaxConnectionCountsJSONSize = len(maxJSONConnCounts)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	Proto ipproto.Proto  `json:"proto,omitzero"`
	Src   netip.AddrPort `json:"src,omitzero"`
	Dst   netip.AddrPort `json:"dst,omitzero"`
}

Connection is a 5-tuple of proto, source and destination IP and port.

func (Connection) IsZero

func (c Connection) IsZero() bool

type ConnectionCounts

type ConnectionCounts struct {
	Connection
	Counts
}

ConnectionCounts is a flattened struct of both a connection and counts.

type Counts

type Counts struct {
	TxPackets uint64 `json:"txPkts,omitzero"`
	TxBytes   uint64 `json:"txBytes,omitzero"`
	RxPackets uint64 `json:"rxPkts,omitzero"`
	RxBytes   uint64 `json:"rxBytes,omitzero"`
}

Counts are statistics about a particular connection.

func (Counts) Add

func (c1 Counts) Add(c2 Counts) Counts

Add adds the counts from both c1 and c2.

func (Counts) IsZero

func (c Counts) IsZero() bool

type CountsByConnection added in v1.90.0

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

CountsByConnection is a count of packets and bytes for each connection. All methods are safe for concurrent calls.

func (*CountsByConnection) Add added in v1.90.0

func (c *CountsByConnection) Add(proto ipproto.Proto, src, dst netip.AddrPort, packets, bytes int, recv bool)

Add adds packets and bytes for the specified connection.

func (*CountsByConnection) Clone added in v1.90.0

func (c *CountsByConnection) Clone() map[Connection]Counts

Clone deep copies the map.

func (*CountsByConnection) Reset added in v1.90.0

func (c *CountsByConnection) Reset()

Reset clear the map.

type Message

type Message struct {
	NodeID tailcfg.StableNodeID `json:"nodeId"` // e.g., "n123456CNTRL"

	Start time.Time `json:"start"` // inclusive
	End   time.Time `json:"end"`   // inclusive

	SrcNode  Node   `json:"srcNode,omitzero"`
	DstNodes []Node `json:"dstNodes,omitempty"`

	VirtualTraffic  []ConnectionCounts `json:"virtualTraffic,omitempty"`
	SubnetTraffic   []ConnectionCounts `json:"subnetTraffic,omitempty"`
	ExitTraffic     []ConnectionCounts `json:"exitTraffic,omitempty"`
	PhysicalTraffic []ConnectionCounts `json:"physicalTraffic,omitempty"`
}

Message is the log message that captures network traffic.

type Node added in v1.92.0

type Node struct {
	// NodeID is the stable ID of the node.
	NodeID tailcfg.StableNodeID `json:"nodeId"`

	// Name is the fully-qualified name of the node.
	Name string `json:"name,omitzero"` // e.g., "carbonite.example.ts.net"

	// Addresses are the Tailscale IP addresses of the node.
	Addresses []netip.Addr `json:"addresses,omitempty"`

	// OS is the operating system of the node.
	OS string `json:"os,omitzero"` // e.g., "linux"

	// User is the user that owns the node.
	// It is not populated if the node is tagged.
	User string `json:"user,omitzero"` // e.g., "johndoe@example.com"

	// Tags are the tags of the node.
	// It is not populated if the node is owned by a user.
	Tags []string `json:"tags,omitempty"` // e.g., ["tag:prod","tag:logs"]
}

Node is information about a node.

Jump to

Keyboard shortcuts

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