saver

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package saver provides the toold for saving a single flow's packets to disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TCP

type TCP struct {
	// Pchan is the channel down which pointers to packets will be sent.
	Pchan chan<- gopacket.Packet
	// UUIDChan is the channel that receives UUIDs with timestamps.
	UUIDchan chan<- UUIDEvent
	// contains filtered or unexported fields
}

TCP provides two channels to allow packets to be saved. A well-buffered channel for packets and a channel to receive the UUID.

func StartNew

func StartNew(ctx context.Context, anon anonymize.IPAnonymizer, dir string, uuidDelay, maxDuration time.Duration, id string, stream bool) *TCP

StartNew creates a new saver.TCP to save a single TCP flow and starts its goroutine. The goroutine can be stopped either by cancelling the passed-in context or by closing the Pchan channel. Closing Pchan is the preferred method, because it is an unambiguous signal that no more packets should be expected for that flow.

It is the caller's responsibility to close Pchan or cancel the context. uuidDelay must be smaller than maxDuration.

func (*TCP) State

func (t *TCP) State() string

State returns the state of the saver in a form suitable for use as a label value in a prometheus vector.

type UUIDEvent

type UUIDEvent struct {
	UUID      string
	Timestamp time.Time
}

UUIDEvent is passed to the saver along with an event arrival timestamp so that the saver can produce an appropriately-named pcap file.

Jump to

Keyboard shortcuts

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