checker-http/checker/definition.go

100 lines
2.8 KiB
Go

// This file is part of the happyDomain (R) project.
// Copyright (c) 2020-2026 happyDomain
// Authors: Pierre-Olivier Mercier, et al.
package checker
import (
"time"
sdk "git.happydns.org/checker-sdk-go/checker"
)
// Version is overridden at link time via -ldflags.
var Version = "built-in"
func (p *httpProvider) Definition() *sdk.CheckerDefinition {
return &sdk.CheckerDefinition{
ID: "http",
Name: "HTTP / HTTPS",
Version: Version,
Availability: sdk.CheckerAvailability{
ApplyToService: true,
LimitToServices: []string{"abstract.Server"},
},
ObservationKeys: []sdk.ObservationKey{ObservationKeyHTTP},
Options: sdk.CheckerOptionsDocumentation{
UserOpts: []sdk.CheckerOptionDocumentation{
{
Id: OptionProbeTimeoutMs,
Type: "number",
Label: "Per-request timeout (ms)",
Description: "Maximum time allowed for a single HTTP/HTTPS request.",
Default: float64(DefaultProbeTimeoutMs),
},
{
Id: OptionMaxRedirects,
Type: "number",
Label: "Max redirects to follow",
Description: "Stop following redirects after this many hops.",
Default: float64(DefaultMaxRedirects),
},
{
Id: OptionUserAgent,
Type: "string",
Label: "User-Agent",
Description: "User-Agent header sent with every request.",
Default: DefaultUserAgent,
},
{
Id: OptionRequireHTTPS,
Type: "bool",
Label: "Require HTTPS",
Description: "Plain HTTP must redirect to HTTPS.",
Default: true,
},
{
Id: OptionRequireHSTS,
Type: "bool",
Label: "Require HSTS",
Description: "HTTPS responses must include a Strict-Transport-Security header.",
Default: true,
},
{
Id: OptionMinHSTSMaxAgeDays,
Type: "number",
Label: "Min HSTS max-age (days)",
Description: "Minimum acceptable max-age value (in days) for HSTS.",
Default: float64(DefaultMinHSTSMaxAge),
},
{
Id: OptionRequireCSP,
Type: "bool",
Label: "Require Content-Security-Policy",
Description: "HTTPS responses must include a Content-Security-Policy header.",
Default: false,
},
},
ServiceOpts: []sdk.CheckerOptionDocumentation{
{
Id: OptionService,
Label: "Service",
AutoFill: sdk.AutoFillService,
Hide: true,
},
{
Id: OptionDomainName,
Label: "Parent domain name",
AutoFill: sdk.AutoFillDomainName,
Hide: true,
},
},
},
Rules: Rules(),
Interval: &sdk.CheckIntervalSpec{
Min: 15 * time.Minute,
Max: 7 * 24 * time.Hour,
Default: 6 * time.Hour,
},
}
}