checker-matrix/checker/interactive.go
Pierre-Olivier Mercier 2af16d3ab9 checker: harden HTTP collection and stabilize report ordering
Validate the federation tester URI placeholder, escape the domain, set
a client timeout, cap the response body, and ship CA certificates in
the scratch image so HTTPS calls succeed. Sort hosts, connection
reports, and errors when rendering so output is deterministic, and
deduplicate TLS problems. Drop the deprecated aggregate Rule() and add
tests for collection and rules.
2026-04-26 04:13:55 +07:00

50 lines
1.3 KiB
Go

//go:build standalone
package checker
import (
"errors"
"net/http"
"strings"
sdk "git.happydns.org/checker-sdk-go/checker"
)
// RenderForm implements server.Interactive.
func (p *matrixProvider) RenderForm() []sdk.CheckerOptionField {
return []sdk.CheckerOptionField{
{
Id: "serviceDomain",
Type: "string",
Label: "Matrix domain",
Placeholder: "matrix.org",
Required: true,
},
{
Id: "federationTesterServer",
Type: "string",
Label: "Federation Tester Server",
Placeholder: "https://federationtester.matrix.org/api/report?server_name=%s",
Default: "https://federationtester.matrix.org/api/report?server_name=%s",
Description: "URL template of the federation tester API; %s is replaced by the domain.",
},
}
}
// ParseForm implements server.Interactive.
func (p *matrixProvider) ParseForm(r *http.Request) (sdk.CheckerOptions, error) {
domain := strings.TrimSpace(r.FormValue("serviceDomain"))
if domain == "" {
return nil, errors.New("matrix domain is required")
}
opts := sdk.CheckerOptions{
"serviceDomain": domain,
}
if tester := strings.TrimSpace(r.FormValue("federationTesterServer")); tester != "" {
opts["federationTesterServer"] = tester
}
return opts, nil
}