Documentation
¶
Overview ¶
Package base provides common utilities for other stenographer libraries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( AllPositions = Positions{-1} NoPositions = Positions{} )
var VerboseLogging = flag.Int("v", -1, "log many verbose logs")
Functions ¶
func ContextDone ¶
ContextDone returns true if a context is complete.
func PacketsToFile ¶
func PacketsToFile(in *PacketChan, out io.Writer) error
PacketsToFile writes all packets from 'in' to 'out', writing out all packets in a valid PCAP file format.
func PathDiskFreePercentage ¶
Types ¶
type Packet ¶
type Packet struct { Data []byte // The actual bytes that make up the packet gopacket.CaptureInfo // Metadata about when/how the packet was captured }
Packet is a single packet with its metadata.
type PacketChan ¶
type PacketChan struct { // C can be used to send packets on this channel in a select. Do NOT // call 'close' on it... instead call the Close function. C chan<- *Packet // contains filtered or unexported fields }
PacketChan provides an async method for passing multiple ordered packets between goroutines.
func ConcatPacketChans ¶
func ConcatPacketChans(ctx context.Context, in <-chan *PacketChan) *PacketChan
ConcatPacketChans concatenates packet chans in order.
func MergePacketChans ¶
func MergePacketChans(ctx context.Context, in []*PacketChan) *PacketChan
MergePacketChans merges an incoming set of packet chans, each sorted by time, returning a new single packet chan that's also sorted by time.
func NewPacketChan ¶
func NewPacketChan(buffer int) *PacketChan
NewPacketChan returns a new PacketChan channel for passing packets around.
func (*PacketChan) Close ¶
func (p *PacketChan) Close(err error)
Close closes the sending channel and sets the PacketChan's error based in its input.
func (*PacketChan) Discard ¶
func (p *PacketChan) Discard()
Discard discards all remaining packets on the receiving end. If you stop using the channel before reading all packets, you must call this function. It's a good idea to defer this regardless.
func (*PacketChan) Done ¶
func (p *PacketChan) Done() <-chan struct{}
Done returns a channel that is closed when this packet channel is complete.
func (*PacketChan) Err ¶
func (p *PacketChan) Err() error
Err gets the current error for the channel, if any exists. This may be called during Next(), but if an error occurs it may only be set after Next() returns false the first time.
func (*PacketChan) Receive ¶
func (p *PacketChan) Receive() <-chan *Packet
Receive provides the channel from which to read packets. It always returns the same channel.
func (*PacketChan) Send ¶
func (p *PacketChan) Send(pkt *Packet)
Send sends a single packet on the channel to the receiver.
type Positions ¶
type Positions []int64
Positions detail the offsets of packets within a blockfile.
func (Positions) Intersect ¶
Intersect returns the intersection of a and b. a and b must be sorted in advance. Returned slice will be sorted. a or b may be returned by Intersect, but neither a nor b will be modified.