Documentation
¶
Overview ¶
Package extract creates SIP messages from pcap packet source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Defragmenter ¶
type Defragmenter interface { DiscardOlderThan(time.Time) int DefragIPv4(*layers.IPv4) (*layers.IPv4, error) }
Defragmenter is the minimum parts of a gopacket/ip4defrag that we care about for packet handling. Use this so we can accept either a default defragmenter or our custom degfragger which handles IP packets with shorter fragments than required by gopacket.
type Extracter ¶
type Extracter struct {
// contains filtered or unexported fields
}
Extracter converts incoming packets into gopacket *layers.SIP structs. It handles reassembling any IP fragments into whole packets, reassembling TCP message segments into a full stream, and then identifying and extracting SIP message data from any UDP packets or TCP streams.
func NewExtracter ¶
func NewExtracter(defragger Defragmenter) *Extracter
NewExtracter creates a Extracter, using the given defragmenter. If the defragmenter is nil, it instantiates a sip-capture/defrag, which handles short packet fragments, unlike the normal gopacket/ip4defrag.
func (*Extracter) Extract ¶
func (e *Extracter) Extract(ctx context.Context, packets <-chan gopacket.Packet, accept func(*layers.SIP) error)
Extract consumes gopackets.Packets from the packet channel, and produces all the capturable SIP messages as *layers.SIP objects into the msgs channel. It handles IPv4 packet defragmentation and TCP stream reassembly.
Extract blocks and will not return until the context is canceled or the packets channel is closed. Incomplete or otherwise defective packets are discarded without any sort of error, though they are recorded in metrics.
func (Extracter) Metrics ¶
func (e Extracter) Metrics() []prometheus.Collector
Metrics returns a slice of prometheus.Collector objects that can be registered. to expose packet capture metrics via Prometheus.
type Metrics ¶
type Metrics struct { Incoming prometheus.Counter Invalid prometheus.Counter Fragments prometheus.Counter ShortFrags prometheus.Counter BadDefrag prometheus.Counter Defrag prometheus.Counter Seen *prometheus.CounterVec Incomplete *prometheus.CounterVec Discarded *prometheus.CounterVec Captured *prometheus.CounterVec }
Metrics contains all the observability data for the packet capture process, in the form of Prometheus metrics.
func NewMetrics ¶
func NewMetrics() *Metrics
NewMetrics creates, but does not register, a set of Prometheus.Collector metrics. Use Metrics.Register to add this to a Prometheus registry to expose the metrics.
func (Metrics) List ¶
func (m Metrics) List() []prometheus.Collector
List returns a slice containing each Prometheus metric, for adding to a prometheus.Registry.