Documentation
¶
Overview ¶
Package capture turns raw packets into attributed flows. The decoding logic here is pure (no libpcap dependency) so it can be unit tested with crafted or replayed packets; the live/offline pcap plumbing lives in source.go.
Index ¶
- func FriendlyName(bsd string) (string, bool)
- func LocalIPs() []string
- type Decoder
- type LiveSupervisor
- func (ls *LiveSupervisor) ListInterfaces() []types.NetIface
- func (ls *LiveSupervisor) Name() string
- func (ls *LiveSupervisor) Paused() bool
- func (ls *LiveSupervisor) PreferredInterface() string
- func (ls *LiveSupervisor) Run(ctx context.Context, out chan<- types.Flow) error
- func (ls *LiveSupervisor) SetOnInterface(fn func(string))
- func (ls *LiveSupervisor) SetPaused(p bool)
- func (ls *LiveSupervisor) SetPreferredInterface(name string) error
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FriendlyName ¶ added in v0.12.0
FriendlyName returns the interface name as-is on Linux (no SystemConfiguration).
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder converts gopacket packets into types.Flow, attributing direction against the set of local interface addresses and feeding observed DNS answers into the supplied cache.
func NewDecoder ¶
NewDecoder builds a Decoder. localIPs is the set of addresses belonging to this host (used to decide upload vs download); dns may be nil to skip DNS learning.
type LiveSupervisor ¶ added in v0.14.0
type LiveSupervisor struct {
// contains filtered or unexported fields
}
LiveSupervisor keeps capture running on the active network interface, re-opening when the default route changes (e.g. Wi-Fi <-> Ethernet).
func NewLiveSupervisor ¶ added in v0.5.0
func NewLiveSupervisor(iface string, dns *dnscache.Cache, prefPath string) *LiveSupervisor
func (*LiveSupervisor) ListInterfaces ¶ added in v0.14.0
func (ls *LiveSupervisor) ListInterfaces() []types.NetIface
func (*LiveSupervisor) Name ¶ added in v0.14.0
func (ls *LiveSupervisor) Name() string
func (*LiveSupervisor) Paused ¶ added in v0.14.0
func (ls *LiveSupervisor) Paused() bool
func (*LiveSupervisor) PreferredInterface ¶ added in v0.14.0
func (ls *LiveSupervisor) PreferredInterface() string
func (*LiveSupervisor) SetOnInterface ¶ added in v0.14.0
func (ls *LiveSupervisor) SetOnInterface(fn func(string))
func (*LiveSupervisor) SetPaused ¶ added in v0.14.0
func (ls *LiveSupervisor) SetPaused(p bool)
func (*LiveSupervisor) SetPreferredInterface ¶ added in v0.14.0
func (ls *LiveSupervisor) SetPreferredInterface(name string) error
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source wraps a pcap handle and decoder, yielding attributed flows.
func OpenLive ¶
OpenLive starts live capture on iface (empty = auto-detect) and returns a Source that reads packets via libpcap.
func OpenOffline ¶
OpenOffline replays a pcap file.