base

package
Version: v0.0.0-...-88424db Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package base provides common utilities for other stenographer libraries.

Index

Constants

This section is empty.

Variables

View Source
var (
	AllPositions = Positions{-1}
	NoPositions  = Positions{}
)
View Source
var VerboseLogging = flag.Int("v", -1, "log many verbose logs")

Functions

func ContextDone

func ContextDone(ctx context.Context) bool

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

func PathDiskFreePercentage(path string) (int, error)

func V

func V(level int, fmt string, args ...interface{})

V provides verbose logging which can be turned on/off with the -v flag.

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

func (a Positions) Intersect(b Positions) (out Positions)

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.

func (Positions) IsAllPositions

func (p Positions) IsAllPositions() bool

func (Positions) Len

func (a Positions) Len() int

func (Positions) Less

func (a Positions) Less(i, j int) bool

func (Positions) Sort

func (a Positions) Sort()

func (Positions) Swap

func (a Positions) Swap(i, j int)

func (Positions) Union

func (a Positions) Union(b Positions) (out Positions)

Union returns the union of a and b. a and b must be sorted in advance. Returned slice will be sorted. a or b may be returned by Union, but neither a nor b will be modified.

Source Files

Jump to

Keyboard shortcuts

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