config

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteIPRDConfigToFile

func WriteIPRDConfigToFile(supplied *IPRDConfig, filePath string) error

WriteIPRDConfigToFile write TOML configuration of supplied to filePath

Types

type FlagInterface

type FlagInterface map[string]*InterfaceConfig

FlagInterface is a flag value representing a interface configuration. Each key is an interface selector (e.g. "eth0" or 1), with attached InterfaceConfig representing supplied options. Options are specified after ":" separated by commas (e.g., "eth0:no-root-network,add-network=172.16").

func (FlagInterface) Configs

func (f FlagInterface) Configs() []InterfaceConfig

Configs returns the flag values as a deterministic list of interface configurations.

func (FlagInterface) Selectors

func (f FlagInterface) Selectors() []string

Selectors returns the configured interface selectors in deterministic order.

func (*FlagInterface) Set

func (f *FlagInterface) Set(value string) error

func (*FlagInterface) String

func (f *FlagInterface) String() string

type FlagSlice

type FlagSlice []string

FlagSlice is a flag value that supports multiple comma-separated values and chaining.

func (*FlagSlice) Set

func (f *FlagSlice) Set(value string) error

func (*FlagSlice) String

func (f *FlagSlice) String() string

type ForwardConfig

type ForwardConfig struct {
	Bind string `toml:"forward_bind" json:"forward_bind"`
	Port int    `toml:"forward_port" json:"forward_port"`
	MDNS bool   `toml:"mdns" json:"mdns"`
}

ForwardConfig describes the daemon's TCP forwarding endpoint and service advertisement.

func DefaultForwardConfig

func DefaultForwardConfig() *ForwardConfig

DefaultForwardConfig returns the default daemon forwarding configuration.

func (*ForwardConfig) Merge

func (cfg *ForwardConfig) Merge(target *ForwardConfig) *ForwardConfig

Merge returns a new ForwardConfig with non-zero values from target applied.

func (*ForwardConfig) Validate

func (cfg *ForwardConfig) Validate() error

Validate returns an error if ForwardConfig contains invalid endpoint values.

type IPRDConfig

type IPRDConfig struct {
	ListenerConfig
	ForwardConfig
}

IPRDConfig combines reusable listener settings with daemon forwarding settings. ListenerConfig is embedded so existing flat TOML and JSON formats are preserved.

func DefaultIPRDConfig

func DefaultIPRDConfig() *IPRDConfig

DefaultIPRDConfig returns the default daemon configuration.

func NewIPRDConfigFromBytes

func NewIPRDConfigFromBytes(data []byte) (*IPRDConfig, error)

NewIPRDConfigFromBytes unmarshals TOML data into IPRDConfig

func NewIPRDConfigFromFile

func NewIPRDConfigFromFile(filePath string) (*IPRDConfig, error)

NewIPRDConfigFromFile reads a TOML configuration file at filePath into IPRDConfig

func ParseConfig

func ParseConfig(supplied *IPRDConfig) (*IPRDConfig, error)

ParseConfig applies daemon defaults, normalizes interface selectors, and validates the result.

func (*IPRDConfig) Merge

func (cfg *IPRDConfig) Merge(target *IPRDConfig) *IPRDConfig

Merge returns a new IPRDConfig with non-zero values from target applied.

func (*IPRDConfig) Validate

func (cfg *IPRDConfig) Validate() error

Validate returns an error if IPRDConfig contains invalid listener or forwarding values.

type InterfaceConfig

type InterfaceConfig struct {
	Selector          string   `toml:"selector" json:"selector"`
	NoRootNetwork     bool     `toml:"no_root_network" json:"no_root_network"`
	FilterKnownPorts  bool     `toml:"filter_known_ports" json:"filter_known_ports"`
	IgnoredDevices    []string `toml:"ignored_devices" json:"ignored_devices"`
	NetworkInclusions []string `toml:"network_inclusions" json:"network_inclusions"`
	NetworkExclusions []string `toml:"network_exclusions" json:"network_exclusions"`
}

InterfaceConfig describes BPF configuration for a specific interface.

func DefaultInterfaceConfig

func DefaultInterfaceConfig() *InterfaceConfig

DefaultInterfaceConfig returns a default InterfaceConfig

type ListenerConfig

type ListenerConfig struct {
	Debug              bool              `toml:"debug" json:"debug"`
	Auto               bool              `toml:"auto" json:"auto"`
	ListenInterfaces   []string          `toml:"listen_interfaces,omitempty" json:"listen_interfaces,omitempty"`
	ListenInterface    string            `toml:"listen_interface,omitempty" json:"listen_interface,omitempty"` // Deprecated: use ListenInterfaces.
	Interfaces         []InterfaceConfig `toml:"interfaces,omitempty" json:"interfaces,omitempty"`
	ForwardKnown       bool              `toml:"forward_known" json:"forward_known"`
	NoRootNetwork      bool              `toml:"no_root_network" json:"no_root_network"`
	FilterKnownPorts   bool              `toml:"filter_known_ports" json:"filter_known_ports"`
	IgnoredDevices     []string          `toml:"ignored_devices" json:"ignored_devices"`
	NetworkInclusions  []string          `toml:"network_inclusions" json:"network_inclusions"`
	NetworkExclusions  []string          `toml:"network_exclusions" json:"network_exclusions"`
	CaptureFile        string            `toml:"capture_file" json:"capture_file"`
	RotateCaptureFiles bool              `toml:"rotate_capture_files" json:"rotate_capture_files"`
}

ListenerConfig describes packet capture and IP report processing behavior.

func DefaultListenerConfig

func DefaultListenerConfig() *ListenerConfig

DefaultListenerConfig returns the default packet listener configuration.

func ParseListenerConfig

func ParseListenerConfig(supplied *ListenerConfig) (*ListenerConfig, error)

ParseListenerConfig applies listener defaults, normalizes interface selectors, and validates the resulting configuration.

func (*ListenerConfig) InterfaceConfigFor

func (cfg *ListenerConfig) InterfaceConfigFor(selector string) InterfaceConfig

InterfaceConfigFor combines the global BPF configuration with overrides for a selector. The returned configuration owns its slice fields and may be modified by the caller.

func (*ListenerConfig) Merge

func (cfg *ListenerConfig) Merge(target *ListenerConfig) *ListenerConfig

Merge returns a new ListenerConfig with non-zero values from target applied.

func (*ListenerConfig) Validate

func (cfg *ListenerConfig) Validate() error

Validate returns an error if ListenerConfig contains invalid values. An empty interface list is valid for partial configuration and config-file updates; ListenerManager.Run requires at least one interface at runtime.

Jump to

Keyboard shortcuts

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