init: fork
This commit is contained in:
60
config.go
Normal file
60
config.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package mellaris
|
||||
|
||||
import (
|
||||
"github.com/DifuseHQ/Mellaris/analyzer"
|
||||
"github.com/DifuseHQ/Mellaris/engine"
|
||||
gfwio "github.com/DifuseHQ/Mellaris/io"
|
||||
"github.com/DifuseHQ/Mellaris/modifier"
|
||||
"github.com/DifuseHQ/Mellaris/ruleset"
|
||||
)
|
||||
|
||||
// Config defines IO, worker, and ruleset settings for the engine.
|
||||
type Config struct {
|
||||
IO IOConfig `mapstructure:"io" yaml:"io"`
|
||||
Workers WorkersConfig `mapstructure:"workers" yaml:"workers"`
|
||||
Ruleset RulesetConfig `mapstructure:"ruleset" yaml:"ruleset"`
|
||||
}
|
||||
|
||||
// IOConfig configures packet IO.
|
||||
type IOConfig struct {
|
||||
QueueSize uint32 `mapstructure:"queueSize" yaml:"queueSize"`
|
||||
ReadBuffer int `mapstructure:"rcvBuf" yaml:"rcvBuf"`
|
||||
WriteBuffer int `mapstructure:"sndBuf" yaml:"sndBuf"`
|
||||
Local bool `mapstructure:"local" yaml:"local"`
|
||||
RST bool `mapstructure:"rst" yaml:"rst"`
|
||||
|
||||
// PacketIO overrides NFQueue creation when set.
|
||||
// When provided, App.Close will call PacketIO.Close.
|
||||
PacketIO gfwio.PacketIO `mapstructure:"-" yaml:"-"`
|
||||
}
|
||||
|
||||
// WorkersConfig configures engine worker behavior.
|
||||
type WorkersConfig struct {
|
||||
Count int `mapstructure:"count" yaml:"count"`
|
||||
QueueSize int `mapstructure:"queueSize" yaml:"queueSize"`
|
||||
TCPMaxBufferedPagesTotal int `mapstructure:"tcpMaxBufferedPagesTotal" yaml:"tcpMaxBufferedPagesTotal"`
|
||||
TCPMaxBufferedPagesPerConn int `mapstructure:"tcpMaxBufferedPagesPerConn" yaml:"tcpMaxBufferedPagesPerConn"`
|
||||
UDPMaxStreams int `mapstructure:"udpMaxStreams" yaml:"udpMaxStreams"`
|
||||
}
|
||||
|
||||
// RulesetConfig configures built-in rule helpers.
|
||||
type RulesetConfig struct {
|
||||
GeoIp string `mapstructure:"geoip" yaml:"geoip"`
|
||||
GeoSite string `mapstructure:"geosite" yaml:"geosite"`
|
||||
}
|
||||
|
||||
// Options configures rules, analyzers, modifiers, and logging.
|
||||
type Options struct {
|
||||
// RulesFile is a YAML rules file on disk. Mutually exclusive with Rules.
|
||||
RulesFile string
|
||||
// Rules provides inline expression rules. Mutually exclusive with RulesFile.
|
||||
Rules []ruleset.ExprRule
|
||||
|
||||
// Analyzers and Modifiers default to built-ins when nil.
|
||||
Analyzers []analyzer.Analyzer
|
||||
Modifiers []modifier.Modifier
|
||||
|
||||
// EngineLogger and RulesetLogger default to no-op loggers when nil.
|
||||
EngineLogger engine.Logger
|
||||
RulesetLogger ruleset.Logger
|
||||
}
|
||||
Reference in New Issue
Block a user