diff --git a/config.yaml.example b/config.yaml.example index ba4e7ec..dd0aa3c 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -37,10 +37,11 @@ storage: dubious_process_list_file: "dubious_processes.data" notification: + interval: 5 # minutes email: enabled: true recipients: - - admin@wuko.top + - smtp: server: port: 465 diff --git a/internal/config/config.go b/internal/config/config.go index b7356cc..5469b75 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -9,7 +9,8 @@ type Config struct { } type NotificationConfig struct { - Email EmailConfig `yaml:"email"` + Email EmailConfig `yaml:"email"` + Interval int `yaml:"interval"` } type EmailConfig struct { diff --git a/internal/notifier/alert_manager.go b/internal/notifier/alert_manager.go index 18a77e0..28fb97d 100644 --- a/internal/notifier/alert_manager.go +++ b/internal/notifier/alert_manager.go @@ -34,7 +34,7 @@ func NewAlerter(cfg config.NotificationConfig) *Alerter { mailer: mail.NewMailer(cfg.Email), eventChan: make(chan AlertEvent, 100), buffer: make([]AlertEvent, 0), - interval: 30 * time.Second, // Todo: 可配置化 + interval: time.Duration(cfg.Interval) * time.Minute, } }