capture

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 7 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func FriendlyName added in v0.12.0

func FriendlyName(bsd string) (string, bool)

FriendlyName has no SystemConfiguration equivalent off macOS; return the BSD name unchanged.

func LocalIPs

func LocalIPs() []string

LocalIPs returns no addresses on unsupported platforms.

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

func NewDecoder(localIPs []string, dns *dnscache.Cache) *Decoder

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.

func (*Decoder) Decode

func (d *Decoder) Decode(pkt gopacket.Packet) (types.Flow, bool)

Decode reduces a packet to a Flow. The bool is false when the packet is not an attributable IP/TCP/UDP packet (e.g. ARP, loopback chatter) or when it is purely intra-host traffic we choose to ignore.

type Source

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

Source is a non-functional placeholder on unsupported platforms.

func NewLiveSupervisor added in v0.5.0

func NewLiveSupervisor(iface string, dns *dnscache.Cache, prefPath string) *Source

NewLiveSupervisor returns a non-functional placeholder on unsupported platforms; its Run reports the unsupported error like the other stubs.

func OpenLive

func OpenLive(iface string, dns *dnscache.Cache) (*Source, error)

func OpenOffline

func OpenOffline(path string, localIPs []string, dns *dnscache.Cache) (*Source, error)

func (*Source) ListInterfaces added in v0.6.0

func (s *Source) ListInterfaces() []types.NetIface

Capturer stubs so the live source satisfies api.Capturer on all platforms.

func (*Source) Name

func (s *Source) Name() string

func (*Source) Paused added in v0.10.0

func (s *Source) Paused() bool

func (*Source) PreferredInterface added in v0.6.0

func (s *Source) PreferredInterface() string

func (*Source) Run

func (s *Source) Run(ctx context.Context, out chan<- types.Flow) error

func (*Source) SetPaused added in v0.10.0

func (s *Source) SetPaused(p bool)

func (*Source) SetPreferredInterface added in v0.6.0

func (s *Source) SetPreferredInterface(name string) error

Jump to

Keyboard shortcuts

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