capture

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 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 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) 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) 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