config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UDPKind is the constant used to define a Kind as UDP
	UDPKind = "udp"

	// TCPKind is the constant used to define a Kind as TCP
	TCPKind = "tcp"

	// ICMPv4Kind is the constant used to define a Kind as ICMPv4
	ICMPv4Kind = "icmpv4"

	// ICMPv6Kind is the constant used to define a Kind as ICMPv6
	ICMPv6Kind = "icmpv6"

	// HTTPKind is the constant used to define a Kind as HTTP
	HTTPKind = "http"

	// HTTPSKind is the constant used to define a Kind as HTTPS
	HTTPSKind = "https"
)

Variables

View Source
var (
	// Cfg exposes the global config
	Cfg *Config
	// Cli exposes the CLI config
	Cli = new(CLI)

	// SupportedProtocols lists the network protocols supported by Melody
	SupportedProtocols = []string{
		TCPKind,
		UDPKind,
		ICMPv4Kind,
		ICMPv6Kind,
		HTTPKind,
		HTTPSKind,
	}
)

Functions

func LoadValidConfigKeysMap

func LoadValidConfigKeysMap() map[string]interface{}

LoadValidConfigKeysMap returns a map of the json keys present in the Config struct

func LoadYAMLTagsOf

func LoadYAMLTagsOf(what interface{}) ([]string, error)

LoadYAMLTagsOf loads the yaml tags of a struct

Types

type CLI

type CLI struct {
	PcapFilePath   *string
	BPF            *string
	Stdout         *bool
	Interface      *string
	Dump           *bool
	ConfigFilePath *string
	ConfigDirPath  *string
	BPFFilePath    *string
	HomeDirPath    *string
	FreeConfig     clihelper.MultiString
}

CLI describes the available CLI config keys

type Config

type Config struct {
	ConfigFilePath string
	ConfigDirPath  string
	BPFFilePath    string
	HomeDirPath    string
	LogsDir        string `yaml:"logs.dir"`

	LogsSensorFile                string `yaml:"logs.sensor.file"`
	LogsSensorMaxSizeRaw          string `yaml:"logs.sensor.rotation.max_size"`
	LogsSensorMaxSize             int
	LogsSensorMaxAge              int  `yaml:"logs.sensor.rotation.max_age"`
	LogsSensorCompressRotatedLogs bool `yaml:"logs.sensor.rotation.compress"`
	LogSensorEnableRotation       bool `yaml:"logs.sensor.rotation.enable"`

	LogsErrorsFile                string `yaml:"logs.errors.file"`
	LogsErrorsMaxSizeRaw          string `yaml:"logs.errors.rotation.max_size"`
	LogsErrorsMaxSize             int
	LogsErrorsMaxAge              int  `yaml:"logs.errors.rotation.max_age"`
	LogsErrorsCompressRotatedLogs bool `yaml:"logs.errors.rotation.compress"`
	LogErrorsEnableRotation       bool `yaml:"logs.errors.rotation.enable"`

	RulesDir string `yaml:"rules.dir"`
	BPFFile  string `yaml:"filters.bpf.file"`
	BPF      string

	Interface            string   `yaml:"listen.interface"`
	MaxPOSTDataSizeRaw   string   `yaml:"logs.http.post.max_size"`
	MaxTCPDataSizeRaw    string   `yaml:"logs.tcp.payload.max_size"`
	MaxUDPDataSizeRaw    string   `yaml:"logs.udp.payload.max_size"`
	MaxICMPv4DataSizeRaw string   `yaml:"logs.icmpv4.payload.max_size"`
	MaxICMPv6DataSizeRaw string   `yaml:"logs.icmpv6.payload.max_size"`
	MatchProtocols       []string `yaml:"rules.match.protocols"`

	ServerHTTPEnable                bool              `yaml:"server.http.enable"`
	ServerHTTPPort                  int               `yaml:"server.http.port"`
	ServerHTTPDir                   string            `yaml:"server.http.dir"`
	ServerHTTPMissingResponseStatus int               `yaml:"server.http.response.missing_status_code"`
	ServerHTTPHeaders               map[string]string `yaml:"server.http.response.headers"`

	ServerHTTPSEnable                bool              `yaml:"server.https.enable"`
	ServerHTTPSPort                  int               `yaml:"server.https.port"`
	ServerHTTPSDir                   string            `yaml:"server.https.dir"`
	ServerHTTPSMissingResponseStatus int               `yaml:"server.https.response.missing_status_code"`
	ServerHTTPSCert                  string            `yaml:"server.https.crt"`
	ServerHTTPSKey                   string            `yaml:"server.https.key"`
	ServerHTTPSHeaders               map[string]string `yaml:"server.https.response.headers"`

	RawDiscardProto4 []string `yaml:"filters.ipv4.proto"`
	RawDiscardProto6 []string `yaml:"filters.ipv6.proto"`

	DiscardProto4 map[string]interface{}
	DiscardProto6 map[string]interface{}

	MaxPOSTDataSize   uint64
	MaxTCPDataSize    uint64
	MaxUDPDataSize    uint64
	MaxICMPv4DataSize uint64
	MaxICMPv6DataSize uint64
	PcapFile          *os.File
}

Config structure which mirrors the yaml file

func NewConfig

func NewConfig() *Config

NewConfig creates a default Config struct

func (*Config) Load

func (cfg *Config) Load() error

Load set the default values and parse the user's config

func (*Config) ParseConfigAt

func (cfg *Config) ParseConfigAt(filepath *string) error

ParseConfigAt parse the config file at the given filepath

Jump to

Keyboard shortcuts

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