From 6dffa66ea949739bea2b55e5394582121a1b5b81 Mon Sep 17 00:00:00 2001 From: wuko233 Date: Thu, 9 Apr 2026 16:19:01 +0800 Subject: [PATCH] =?UTF-8?q?[notifier]=20=E6=94=AF=E6=8C=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8F=91=E4=BF=A1=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yaml.example | 3 ++- internal/config/config.go | 3 ++- internal/notifier/alert_manager.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) 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, } }