You've already forked caddy-opnsense-blocker
Add on-demand IP investigation and richer IP details
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user