mirror of
https://github.com/outbackdingo/labca.git
synced 2026-01-27 10:19:34 +00:00
64 lines
1.7 KiB
Diff
64 lines
1.7 KiB
Diff
diff --git a/cmd/notify-mailer/main.go b/cmd/notify-mailer/main.go
|
|
index a05366c3..da9d78c8 100644
|
|
--- a/cmd/notify-mailer/main.go
|
|
+++ b/cmd/notify-mailer/main.go
|
|
@@ -37,6 +37,7 @@ type mailer struct {
|
|
recipients []recipient
|
|
targetRange interval
|
|
sleepInterval time.Duration
|
|
+ pa *policy.AuthorityImpl
|
|
parallelSends uint
|
|
}
|
|
|
|
@@ -201,7 +202,7 @@ func (m *mailer) run(ctx context.Context) error {
|
|
continue
|
|
}
|
|
|
|
- err := policy.ValidEmail(w.address)
|
|
+ err := m.pa.ValidEmail(w.address)
|
|
if err != nil {
|
|
m.log.Infof("Skipping %q due to policy violation: %s", w.address, err)
|
|
continue
|
|
@@ -502,7 +503,9 @@ type Config struct {
|
|
NotifyMailer struct {
|
|
DB cmd.DBConfig
|
|
cmd.SMTPConfig
|
|
+ cmd.HostnamePolicyConfig
|
|
}
|
|
+ PA cmd.PAConfig
|
|
Syslog cmd.SyslogConfig
|
|
}
|
|
|
|
@@ -570,6 +573,15 @@ func main() {
|
|
log.Infof("While reading the recipient list file %s", probs)
|
|
}
|
|
|
|
+ // Validate PA config and set defaults if needed
|
|
+ cmd.FailOnError(cfg.PA.CheckChallenges(), "Invalid PA configuration")
|
|
+
|
|
+ logger := cmd.NewLogger(cmd.SyslogConfig{StdoutLevel: 7})
|
|
+ pa, err := policy.New(cfg.PA.Challenges, logger)
|
|
+ cmd.FailOnError(err, "Failed to create PA")
|
|
+ err = pa.LoadHostnamePolicyFile(cfg.NotifyMailer.HostnamePolicyFile)
|
|
+ cmd.FailOnError(err, "Failed to load HostnamePolicyFile")
|
|
+
|
|
var mailClient bmail.Mailer
|
|
if *dryRun {
|
|
log.Infof("Starting %s in dry-run mode", cmd.VersionString())
|
|
@@ -585,6 +597,7 @@ func main() {
|
|
cfg.NotifyMailer.Username,
|
|
smtpPassword,
|
|
nil,
|
|
+ nil,
|
|
*address,
|
|
log,
|
|
metrics.NoopRegisterer,
|
|
@@ -605,6 +618,7 @@ func main() {
|
|
end: *end,
|
|
},
|
|
sleepInterval: *sleep,
|
|
+ pa: pa,
|
|
parallelSends: *parallelSends,
|
|
}
|
|
|