33 lines
1 KiB
Go
33 lines
1 KiB
Go
package checker
|
|
|
|
import (
|
|
"context"
|
|
|
|
sdk "git.happydns.org/checker-sdk-go/checker"
|
|
)
|
|
|
|
// nullMXRule reports whether the domain declares a null MX (RFC 7505).
|
|
// This is surfaced as a distinct rule so the rest of the rules can short
|
|
// out cleanly: every other rule skips when data.MX.NullMX is true.
|
|
type nullMXRule struct{}
|
|
|
|
func (r *nullMXRule) Name() string { return "smtp.null_mx" }
|
|
func (r *nullMXRule) Description() string {
|
|
return "Reports whether the domain publishes a null MX (RFC 7505), which declares it does not accept mail."
|
|
}
|
|
|
|
func (r *nullMXRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
|
|
data, errSt := loadSMTPData(ctx, obs)
|
|
if errSt != nil {
|
|
return []sdk.CheckState{*errSt}
|
|
}
|
|
if data.MX.NullMX {
|
|
return []sdk.CheckState{{
|
|
Status: sdk.StatusInfo,
|
|
Message: "Domain refuses all email via null MX (RFC 7505).",
|
|
Code: CodeNullMX,
|
|
Meta: map[string]any{"null_mx": true},
|
|
}}
|
|
}
|
|
return []sdk.CheckState{passState("smtp.null_mx.ok", "Domain does not declare a null MX.")}
|
|
}
|