config

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveConfig

func SaveConfig(config *Config, filename string) error

SaveConfig saves configuration to a TOML file

Types

type BackendConfig

type BackendConfig struct {
	Type string `toml:"type"`
}

BackendConfig contains backend storage configuration

type Config

type Config struct {
	Server    ServerConfig    `toml:"server"`
	Plugins   PluginsConfig   `toml:"plugins"`
	RateLimit RateLimitConfig `toml:"rateLimit"`
	Logging   LoggingConfig   `toml:"logging"`
}

Config represents the main application configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads configuration from a TOML file

type HeadersConfig

type HeadersConfig struct {
	Enabled   bool   `toml:"enabled"`
	TorHeader string `toml:"torHeader"`
	BanHeader string `toml:"banHeader"`
}

HeadersConfig contains HTTP headers configuration

type LoggingConfig

type LoggingConfig struct {
	Level  string `toml:"level"`
	Format string `toml:"format"`
}

LoggingConfig contains logging configuration

type PluginsConfig

type PluginsConfig struct {
	Enabled   bool                      `toml:"enabled"`
	Directory string                    `toml:"directory"`
	Config    map[string]map[string]any `toml:"config"`
}

PluginsConfig contains plugin system configuration

type RateLimitConfig

type RateLimitConfig struct {
	Enabled                  bool            `toml:"enabled"`
	MaxConcurrentConnections int             `toml:"maxConcurrentConnections"`
	ConnectionRate           int             `toml:"connectionRate"`
	HTTPRequestRate          int             `toml:"httpRequestRate"`
	HTTPErrorRate            int             `toml:"httpErrorRate"`
	CrawlerBlockDuration     time.Duration   `toml:"crawlerBlockDuration"`
	Backend                  BackendConfig   `toml:"backend"`
	Tor                      TorConfig       `toml:"tor"`
	Headers                  HeadersConfig   `toml:"headers"`
	Whitelist                WhitelistConfig `toml:"whitelist"`
}

RateLimitConfig contains rate limiting configuration

type ServerConfig

type ServerConfig struct {
	Bind    string `toml:"bind"`
	DataDir string `toml:"dataDir"`
}

ServerConfig contains server-specific configuration

type TorConfig

type TorConfig struct {
	Enabled                   bool          `toml:"enabled"`
	MaxRequestsPerConnection  int           `toml:"maxRequestsPerConnection"`
	MaxConcurrentConnections  int           `toml:"maxConcurrentConnections"`
	ConnectionRate            int           `toml:"connectionRate"`
	ConnectionRateWindow      time.Duration `toml:"connectionRateWindow"`
	BanDuration               time.Duration `toml:"banDuration"`
	RepeatOffenderBanDuration time.Duration `toml:"repeatOffenderBanDuration"`
	ExitNodeListURL           string        `toml:"exitNodeListURL"`
	UpdateInterval            time.Duration `toml:"updateInterval"`
	CacheFilePath             string        `toml:"cacheFilePath"`
	GlobalRateLimit           bool          `toml:"globalRateLimit"`
	GlobalRequestRate         int           `toml:"globalRequestRate"`
	GlobalRateWindow          time.Duration `toml:"globalRateWindow"`
	GlobalBanDuration         time.Duration `toml:"globalBanDuration"`
}

TorConfig contains Tor-specific rate limiting configuration

type WhitelistConfig

type WhitelistConfig struct {
	IPs []string `toml:"ips"`
}

WhitelistConfig contains IP whitelist configuration

Jump to

Keyboard shortcuts

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