sniffer

package
v6.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListDeviceNames

func ListDeviceNames(withDescription bool, withIP bool) ([]string, error)

ListDevicesNames returns the list of adapters available for sniffing on this computer. If the withDescription parameter is set to true, a human readable version of the adapter name is added. If the withIP parameter is set to true, IP address of the adapter is added.

Types

type Sniffer

type Sniffer struct {
	// contains filtered or unexported fields
}

Sniffer provides packet sniffing capabilities, forwarding packets read to a Worker.

func New

func New(
	testMode bool,
	filter string,
	factory WorkerFactory,
	interfaces config.InterfacesConfig,
) (*Sniffer, error)

New create a new Sniffer instance. Settings are validated in a best effort only, but no device is opened yet. Accessing and configuring the actual device is done by the Run method.

func (*Sniffer) Run

func (s *Sniffer) Run() error

Run opens the sniffing device and processes packets being read from that device. Worker instances are instantiated as needed.

func (*Sniffer) Stop

func (s *Sniffer) Stop() error

Stop marks a sniffer as stopped. The Run method will return once the stop signal has been given.

type Worker

type Worker interface {
	OnPacket(data []byte, ci *gopacket.CaptureInfo)
}

Worker defines the callback interfaces a Sniffer instance will use to forward packets.

type WorkerFactory

type WorkerFactory func(layers.LinkType) (Worker, error)

WorkerFactory constructs a new worker instance for use with a Sniffer.

Jump to

Keyboard shortcuts

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