import "github.com/dreadl0ck/netcap/collector"
Provides a mechanism to collect network packets from a network interface on macOS, linux and windows
atomicPcapGoWriter.go batch.go bpf.go collector.go config.go live_linux.go metrics.go pcap.go pcapNG.go pcapUtils.go utils.go worker.go
DumpProto prints a protobuff Message.
IsPcap checks wheter a file is a PCAP file
AtomicPcapGoWriter is a symchronized PCAP writer that counts the number of packets written.
func NewAtomicPcapGoWriter(w *pcapgo.Writer) *AtomicPcapGoWriter
NewAtomicPcapGoWriter takes a pcapgo.Writer and returns an atomic version
func (a *AtomicPcapGoWriter) WritePacket(ci gopacket.CaptureInfo, data []byte) error
WritePacket writes a packet into the writer.
BatchInfo contains information about a Batch source.
type Collector struct {
// contains filtered or unexported fields
}
Collector provides an interface to collect data from PCAP or a network interface.
New returns a new Collector instance.
CollectBPF open the named PCAP file and sets the specified BPF filter.
CollectLive starts collection of data from the given interface. optionally a BPF can be supplied. this is the linux version that uses the pure go version from pcapgo to fetch packets live.
CollectPcap implements parallel decoding of incoming packets.
CollectPcapNG implements parallel decoding of incoming packets.
FreeOSMemory forces freeing memory
GetNumPackets returns the current number of processed packets
Init sets up the collector and starts the configured number of workers must be called prior to usage of the collector instance.
func (c *Collector) InitBatching(maxSize int, bpf string, in string) ([]BatchInfo, *pcap.Handle, error)
InitBatching initializes batching mode and returns an array of Batchinfos and the pcap handle closing the handle must be done by the caller.
PrintConfiguration dumps the current collector config to stdout
Stats prints collector statistics.
type Config struct { Live bool WriteUnknownPackets bool Workers int PacketBufferSize int SnapLen int Promisc bool EncoderConfig encoder.Config BaseLayer gopacket.LayerType DecodeOptions gopacket.DecodeOptions }
Config contains configuration parameters for the Collector instance.
Package collector imports 30 packages (graph) and is imported by 10 packages. Updated 2020-03-29. Refresh now. Tools for package owners.