2

Add on-demand IP investigation and richer IP details

This commit is contained in:
2026-03-12 01:53:44 +01:00
parent 33dd9bac76
commit c5e1c4ff36
13 changed files with 1561 additions and 144 deletions

View File

@@ -36,11 +36,12 @@ func (d Duration) MarshalYAML() (any, error) {
}
type Config struct {
Server ServerConfig `yaml:"server"`
Storage StorageConfig `yaml:"storage"`
OPNsense OPNsenseConfig `yaml:"opnsense"`
Profiles map[string]ProfileConfig `yaml:"profiles"`
Sources []SourceConfig `yaml:"sources"`
Server ServerConfig `yaml:"server"`
Storage StorageConfig `yaml:"storage"`
Investigation InvestigationConfig `yaml:"investigation"`
OPNsense OPNsenseConfig `yaml:"opnsense"`
Profiles map[string]ProfileConfig `yaml:"profiles"`
Sources []SourceConfig `yaml:"sources"`
}
type ServerConfig struct {
@@ -54,6 +55,14 @@ type StorageConfig struct {
Path string `yaml:"path"`
}
type InvestigationConfig struct {
Enabled bool `yaml:"enabled"`
RefreshAfter Duration `yaml:"refresh_after"`
Timeout Duration `yaml:"timeout"`
UserAgent string `yaml:"user_agent"`
SpamhausEnabled bool `yaml:"spamhaus_enabled"`
}
type OPNsenseConfig struct {
Enabled bool `yaml:"enabled"`
BaseURL string `yaml:"base_url"`
@@ -157,6 +166,21 @@ func (c *Config) applyDefaults() error {
if c.Storage.Path == "" {
c.Storage.Path = "./data/caddy-opnsense-blocker.db"
}
if !c.Investigation.Enabled {
c.Investigation.Enabled = true
}
if c.Investigation.RefreshAfter.Duration == 0 {
c.Investigation.RefreshAfter.Duration = 24 * time.Hour
}
if c.Investigation.Timeout.Duration == 0 {
c.Investigation.Timeout.Duration = 8 * time.Second
}
if strings.TrimSpace(c.Investigation.UserAgent) == "" {
c.Investigation.UserAgent = "caddy-opnsense-blocker/0.2"
}
if !c.Investigation.SpamhausEnabled {
c.Investigation.SpamhausEnabled = true
}
if c.OPNsense.Timeout.Duration == 0 {
c.OPNsense.Timeout.Duration = 8 * time.Second