config

package
v4.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: GPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package config is for parsing goprobe config files.

Index

Constants

View Source
const (
	DefaultRingBufferBlockSize   int = 1 * 1024 * 1024  // DefaultRingBufferBlockSize : 1 MB
	DefaultRingBufferNumBlocks   int = 4                // DefaultRingBufferNumBlocks : 4
	DefaultLocalBufferSizeLimit  int = 64 * 1024 * 1024 // DefaultLocalBufferSizeLimit : 64 MB (globally, not per interface)
	DefaultLocalBufferNumBuffers int = 1                // DefaultLocalBufferNumBuffers : 1 (should suffice)
)
View Source
const (
	// ServiceName is the name of the service as it will show up in telemetry such as metrics, logs, traces, etc.
	ServiceName = "goprobe"
)

Variables

This section is empty.

Functions

func IsRegexpInterfaceMatcher added in v4.1.22

func IsRegexpInterfaceMatcher(iface IfaceName) bool

IsRegexpInterfaceMatcher determines if the given interface name is a regexp matcher

Types

type APIConfig

type APIConfig struct {
	Addr                string               `json:"addr" yaml:"addr" mapstructure:"addr"`
	Metrics             bool                 `json:"metrics" yaml:"metrics" mapstructure:"metrics"`
	DisableIfaceMetrics bool                 `json:"disable_iface_metrics" yaml:"disable_iface_metrics" mapstructure:"disable_iface_metrics"`
	Profiling           bool                 `json:"profiling" yaml:"profiling" mapstructure:"profiling"`
	Timeout             int                  `json:"request_timeout" yaml:"request_timeout" mapstructure:"request_timeout"`
	Keys                []string             `json:"keys" yaml:"keys" mapstructure:"keys"`
	QueryRateLimit      QueryRateLimitConfig `json:"query_rate_limit" yaml:"query_rate_limit" mapstructure:"query_rate_limit"`
}

APIConfig stores goProbe's API configuration

type AutoDetectionConfig added in v4.2.0

type AutoDetectionConfig struct {
	// Enabled: enables / disables auto-detection of interfaces
	Enabled bool `json:"enabled" yaml:"enabled" mapstructure:"enabled" doc:"Enables / disables auto-detection of interfaces" example:"true"`
	// Exclude: a list of interface names to exclude from auto-detection
	Exclude []IfaceName `` /* 133-byte string literal not displayed */
}

AutoDetectionConfig stores the auto-detection configuration for interfaces

func (AutoDetectionConfig) ExcludeMatcher added in v4.2.1

func (a AutoDetectionConfig) ExcludeMatcher() (*IfaceMatcher, bool, error)

ExcludeMatcher creates an IfaceMatcher from the autodetection configuration (to be used for exclusions)

func (AutoDetectionConfig) Validate added in v4.2.1

func (a AutoDetectionConfig) Validate() error

Validate validates the auto-detection configuration

type CallbackFn

type CallbackFn func(context.Context, *Config) (enabled, updated, disabled capturetypes.IfaceChanges, err error)

CallbackFn denotes a function to be called upon successful reload of the configuration

type CaptureConfig

type CaptureConfig struct {
	// IgnoreVLANs: enables / disables skipping of VLAN-tagged packets
	IgnoreVLANs bool `` /* 152-byte string literal not displayed */
	// Promisc: enables / disables promiscuous capture mode
	Promisc bool `` /* 130-byte string literal not displayed */
	// RingBuffer: denotes the kernel ring buffer configuration of this interface
	RingBuffer *RingBufferConfig `json:"ring_buffer" yaml:"ring_buffer" mapstructure:"ring_buffer" doc:"Kernel ring buffer configuration for interface"`
	// ExtraBPFFilters: allows setting additional BPF filter instructions during capture
	ExtraBPFFilters []bpf.RawInstruction `` /* 147-byte string literal not displayed */
	// Disable: explicitly disables capture on this interface
	Disable bool `json:"disable" yaml:"disable" mapstructure:"disable" doc:"Explicitly disables capture on this interface" example:"true"`
}

CaptureConfig stores the capture / buffer related configuration for an individual interface

func DefaultCaptureConfig added in v4.2.0

func DefaultCaptureConfig() CaptureConfig

DefaultCaptureConfig returns the default capture configuration

func (CaptureConfig) Equals

func (c CaptureConfig) Equals(cfg CaptureConfig) bool

Equals compares c to cfg and returns true if all fields are identical

type Config

type Config struct {
	sync.Mutex
	DB            DBConfig            `json:"db" yaml:"db" mapstructure:"db"`
	AutoDetection AutoDetectionConfig `json:"autodetection" yaml:"autodetection" mapstructure:"autodetection" doc:"Configures auto-detection of interfaces"`
	Interfaces    Ifaces              `json:"interfaces" yaml:"interfaces" mapstructure:"interfaces"`
	SyslogFlows   bool                `json:"syslog_flows" yaml:"syslog_flows" mapstructure:"syslog_flows"`
	API           APIConfig           `json:"api" yaml:"api" mapstructure:"api"`
	LocalBuffers  LocalBufferConfig   `json:"local_buffers" yaml:"local_buffers" mapstructure:"local_buffers"`
}

Config stores goProbe's configuration

func Parse

func Parse(src io.Reader) (*Config, error)

Parse attempts to read the configuration from an io.Reader

func ParseFile

func ParseFile(path string) (*Config, error)

ParseFile reads in a configuration from a file at `path`. If provided, fields are overwritten from the default configuration

func (*Config) Validate

func (c *Config) Validate() error

Validate checks all config parameters

type DBConfig

type DBConfig struct {
	Path        string      `json:"path" yaml:"path" mapstructure:"path"`
	EncoderType string      `json:"encoder_type" yaml:"encoder_type" mapstructure:"encoder_type"`
	Permissions fs.FileMode `json:"permissions" yaml:"permissions" mapstructure:"permissions"`
}

DBConfig stores the local on-disk database configuration

type IfaceMatcher added in v4.1.22

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

IfaceMatcher stores the per-interface configuration (including regexp matchers)

func (*IfaceMatcher) FindMatch added in v4.2.1

func (m *IfaceMatcher) FindMatch(iface string) (CaptureConfig, bool)

FindMatch attempts to find a matching interface configuration for the given interface name

type IfaceName added in v4.1.22

type IfaceName = string

IfaceName denotes the name of a network interface Can also be a regexp matcher (e.g. "/^eth[0-9]+$/")

type Ifaces

type Ifaces map[IfaceName]CaptureConfig

Ifaces maps interface names to their capture configuration

func (Ifaces) Matcher added in v4.1.22

func (i Ifaces) Matcher() (*IfaceMatcher, bool, error)

Matcher creates an IfaceMatcher from the Ifaces configuration

func (Ifaces) Validate

func (i Ifaces) Validate() error

Validate validates the interfaces configuration

type InterfaceConfigs added in v4.2.0

type InterfaceConfigs struct {
}

InterfaceConfigs stores the configuration for all interfaces

type LocalBufferConfig

type LocalBufferConfig struct {
	// SizeLimit denotes the maximum size of the local buffers (globally)
	// used to continue capturing while the capture is (b)locked
	SizeLimit int `json:"size_limit" yaml:"size_limit" mapstructure:"size_limit"`

	// NumBuffers denotes the number of buffers (and hence maximum concurrency
	// of Status() calls). This should be left at default unless absolutely required
	NumBuffers int `json:"num_buffers" yaml:"num_buffers" mapstructure:"num_buffers"`
}

LocalBufferConfig stores the shared local in-memory buffer configuration

type LogConfig

type LogConfig struct {
	Destination string `json:"destination" yaml:"destination" mapstructure:"destination"`
	Level       string `json:"level" yaml:"level" mapstructure:"level"`
	Encoding    string `json:"encoding" yaml:"encoding" mapstructure:"encoding"`
}

LogConfig stores the logging configuration

type Monitor

type Monitor struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Monitor denotes a config monitor / manager

func NewMonitor

func NewMonitor(path string, opts ...MonitorOption) (*Monitor, error)

NewMonitor instantiates a new config monitor and performs an initial read of the provided config file

func (*Monitor) Apply

func (m *Monitor) Apply(ctx context.Context, fn CallbackFn) (enabled, updated, disabled capturetypes.IfaceChanges, err error)

Apply peforms a callback to the provided function and returns its result

func (*Monitor) GetConfig

func (m *Monitor) GetConfig() (cfg *Config)

GetConfig safely returns the current configuration

func (*Monitor) PutConfig

func (m *Monitor) PutConfig(cfg *Config)

PutConfig safely updates the configuration with a new one

func (*Monitor) PutIfaceConfig

func (m *Monitor) PutIfaceConfig(cfg Ifaces)

PutIfaceConfig safely updates the interface configuration with a new one

func (*Monitor) Reload

func (m *Monitor) Reload(ctx context.Context, fn CallbackFn) (enabled, updated, disabled capturetypes.IfaceChanges, err error)

Reload triggers a config reload from disk and triggers the execution of the provided callback (if any)

func (*Monitor) Start

func (m *Monitor) Start(ctx context.Context, fn CallbackFn)

Start initializaes the config monitor background task(s)

type MonitorOption

type MonitorOption func(*Monitor)

MonitorOption denotes a functional option for a config monitor

func WithInitialConfig added in v4.2.0

func WithInitialConfig(cfg *Config) MonitorOption

WithInitialConfig sets an initial configuration for the monitor. It will override the one read from `path` in NewMonitor

func WithReloadInterval

func WithReloadInterval(interval time.Duration) MonitorOption

WithReloadInterval sets a non-default config reload interval

type QueryRateLimitConfig

type QueryRateLimitConfig struct {
	MaxReqPerSecond rate.Limit `json:"max_req_per_sec" yaml:"max_req_per_sec" mapstructure:"max_req_per_sec"`
	MaxBurst        int        `json:"max_burst" yaml:"max_burst" mapstructure:"max_burst"`
	MaxConcurrent   int        `json:"max_concurrent" yaml:"max_concurrent" mapstructure:"max_concurrent"`
}

QueryRateLimitConfig contains query rate limiting related config arguments / parameters

type RingBufferConfig

type RingBufferConfig struct {
	// BlockSize: specifies the size of a block, which defines how many packets can be held within a block
	BlockSize int `` /* 172-byte string literal not displayed */

	// NumBlocks: guides how many blocks are part of the ring buffer
	NumBlocks int `` /* 142-byte string literal not displayed */
}

RingBufferConfig stores the kernel ring buffer related configuration for an individual interface

func (*RingBufferConfig) Equals

func (r *RingBufferConfig) Equals(cfg *RingBufferConfig) bool

Equals compares r to cfg and returns true if all fields are identical

Jump to

Keyboard shortcuts

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