types

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package types holds the data structures shared between the capture daemon, the aggregation/storage layer and the HTTP API. Keeping them in one place (instead of inside internal/) lets external tooling and tests import them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppTraffic

type AppTraffic struct {
	PID         int    `json:"pid"`
	Name        string `json:"name"`
	Path        string `json:"path"`
	RxBytes     uint64 `json:"rxBytes"`
	TxBytes     uint64 `json:"txBytes"`
	Connections int    `json:"connections"`
}

AppTraffic is the per-application aggregate returned by the API.

func (AppTraffic) Total

func (a AppTraffic) Total() uint64

Total returns rx+tx, convenient for ranking.

type ConnKey

type ConnKey struct {
	Proto      Protocol
	LocalPort  uint16
	RemoteIP   string
	RemotePort uint16
}

ConnKey is the normalised identity of a connection, used to look up the owning process and to attribute DNS-resolved domains.

type Direction

type Direction string

Direction describes whether bytes were sent or received by the local host.

const (
	// DirOut is traffic originating from this machine (upload / tx).
	DirOut Direction = "out"
	// DirIn is traffic destined for this machine (download / rx).
	DirIn Direction = "in"
)

type DomainStat

type DomainStat struct {
	Domain   string `json:"domain"`
	AppName  string `json:"appName"`
	RxBytes  uint64 `json:"rxBytes"`
	TxBytes  uint64 `json:"txBytes"`
	Category string `json:"category,omitempty"`
}

DomainStat is the per-domain aggregate returned by the API. Category is a neutral grouping (cloud/cdn/media/social/ai/…), used for display only.

func (DomainStat) Total

func (d DomainStat) Total() uint64

Total returns rx+tx.

type Flow

type Flow struct {
	Timestamp time.Time
	Proto     Protocol
	Direction Direction
	// LocalPort/RemotePort/RemoteIP identify the connection the packet belongs
	// to, normalised so that "local" is always this host regardless of the
	// packet direction. They form the key used to resolve the owning process.
	LocalPort  uint16
	RemoteIP   string
	RemotePort uint16
	// Bytes is the IP payload length (L3) of the packet.
	Bytes uint64
}

Flow is a single observed packet reduced to the fields netscope cares about. It is the unit emitted by the capture layer and consumed by the engine.

type Process

type Process struct {
	PID  int    `json:"pid"`
	Name string `json:"name"` // executable / bundle display name
	Path string `json:"path"` // absolute executable path
}

Process identifies the application a flow is attributed to.

type Protocol

type Protocol string

Protocol identifies the L4 protocol a flow uses.

const (
	ProtoTCP Protocol = "tcp"
	ProtoUDP Protocol = "udp"
)

type Snapshot

type Snapshot struct {
	Time         time.Time    `json:"time"`
	SessionStart time.Time    `json:"sessionStart"`
	Apps         []AppTraffic `json:"apps"`
	Domains      []DomainStat `json:"domains"`
	TotalRx      uint64       `json:"totalRx"`
	TotalTx      uint64       `json:"totalTx"`
	RxPerSec     uint64       `json:"rxPerSec"`
	TxPerSec     uint64       `json:"txPerSec"`
	// ActiveApps is how many apps sent/received within the recent activity
	// window (not the cumulative count).
	ActiveApps int    `json:"activeApps"`
	Interface  string `json:"interface"`
}

Snapshot is a point-in-time view pushed to live dashboard clients.

Apps/Domains are SESSION-CUMULATIVE: they accumulate since the daemon started and never reset on a storage flush, so the dashboard tables stay stable instead of emptying every flush interval. RxPerSec/TxPerSec are the instantaneous rates (expected to fluctuate).

type TimePoint

type TimePoint struct {
	Time    time.Time `json:"time"`
	RxBytes uint64    `json:"rxBytes"`
	TxBytes uint64    `json:"txBytes"`
}

TimePoint is one bucket of a time-series response.

Jump to

Keyboard shortcuts

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