Initial commit
This commit is contained in:
commit
485c5a4a1d
33 changed files with 5407 additions and 0 deletions
39
checker/rules_simple.go
Normal file
39
checker/rules_simple.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package checker
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||
)
|
||||
|
||||
// simpleConcernRule is the common shape for "load SMTPData, derive the
|
||||
// issues, keep only those whose Code matches one of `codes`, and emit
|
||||
// either the matching states or a single pass state".
|
||||
type simpleConcernRule struct {
|
||||
name string
|
||||
description string
|
||||
codes []string
|
||||
passCode string
|
||||
passMessage string
|
||||
}
|
||||
|
||||
func (r *simpleConcernRule) Name() string { return r.name }
|
||||
func (r *simpleConcernRule) Description() string { return r.description }
|
||||
|
||||
func (r *simpleConcernRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
|
||||
data, errSt := loadSMTPData(ctx, obs)
|
||||
if errSt != nil {
|
||||
return []sdk.CheckState{*errSt}
|
||||
}
|
||||
// Null-MX declares the domain does not accept mail; every other rule
|
||||
// becomes vacuous. Return "not tested" so those lines do not count as
|
||||
// a pass or fail in the aggregator.
|
||||
if data.MX.NullMX {
|
||||
return []sdk.CheckState{notTestedState(r.name+".skipped", "Skipped: domain declares a null MX (refuses mail).")}
|
||||
}
|
||||
issues := issuesByCodes(data, r.codes...)
|
||||
if len(issues) == 0 {
|
||||
return []sdk.CheckState{passState(r.passCode, r.passMessage)}
|
||||
}
|
||||
return statesFromIssues(issues)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue