checker-blacklist/checker/definition.go
Pierre-Olivier Mercier ce59a976d5
All checks were successful
continuous-integration/drone/tag Build is passing
continuous-integration/drone/push Build is passing
Expose one rule per source with rule-scoped options
Each registered Source now becomes its own CheckRule (name = source ID)
implementing CheckRuleWithOptions, so the host can toggle blacklists
individually and the per-source option fields show up under the rule
that owns them instead of one flat global option list.

Collect honours the host's per-rule enable map (via the SDK's
RuleEnabled context helper) and skips the network call for disabled
sources entirely, not just their evaluation.
2026-05-19 22:12:31 +08:00

48 lines
1.1 KiB
Go

package checker
import (
"time"
sdk "git.happydns.org/checker-sdk-go/checker"
)
// Version is overridden at link time by the standalone or plugin entrypoints.
var Version = "built-in"
// Definition assembles the checker definition. Per-source option fields
// live on each per-source rule (CheckRuleWithOptions); the global Options
// only carries the shared domain target.
func Definition() *sdk.CheckerDefinition {
opts := sdk.CheckerOptionsDocumentation{
DomainOpts: []sdk.CheckerOptionDocumentation{
{
Id: "domain_name",
Label: "Domain name",
AutoFill: sdk.AutoFillDomainName,
},
},
}
return &sdk.CheckerDefinition{
ID: "blacklist",
Name: "Blacklist & reputation",
Version: Version,
Availability: sdk.CheckerAvailability{
ApplyToDomain: true,
},
ObservationKeys: []sdk.ObservationKey{ObservationKeyBlacklist},
Options: opts,
Rules: Rules(),
Interval: &sdk.CheckIntervalSpec{
Min: 30 * time.Minute,
Max: 24 * time.Hour,
Default: 6 * time.Hour,
},
HasHTMLReport: true,
HasMetrics: true,
}
}