77 lines
2.3 KiB
Go
77 lines
2.3 KiB
Go
//go:build standalone
|
|
|
|
package checker
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"strings"
|
|
|
|
sdk "git.happydns.org/checker-sdk-go/checker"
|
|
)
|
|
|
|
// RenderForm advertises the minimal inputs a human needs to run the
|
|
// checker from its standalone /check page.
|
|
func (p *autoconfigProvider) RenderForm() []sdk.CheckerOptionField {
|
|
return []sdk.CheckerOptionField{
|
|
{
|
|
Id: sdk.AutoFillDomainName,
|
|
Type: "string",
|
|
Label: "Domain name",
|
|
Placeholder: "example.com",
|
|
Required: true,
|
|
Description: "Domain to probe for email autoconfiguration.",
|
|
},
|
|
{
|
|
Id: "probeEmail",
|
|
Type: "string",
|
|
Label: "Local-part used in probes",
|
|
Placeholder: "test",
|
|
Default: "test",
|
|
Description: "Local part sent in the autoconfig URL query string (before @).",
|
|
},
|
|
{
|
|
Id: "tryISPDB",
|
|
Type: "bool",
|
|
Label: "Try Mozilla ISPDB fallback",
|
|
Default: true,
|
|
Description: "Probe Mozilla's public Thunderbird ISPDB when the domain itself does not publish autoconfig.",
|
|
},
|
|
{
|
|
Id: "tryHTTPAutoconfig",
|
|
Type: "bool",
|
|
Label: "Allow plain-HTTP fallback probe",
|
|
Default: false,
|
|
Description: "Also attempt the plain-HTTP variant of autoconfig.<domain>.",
|
|
},
|
|
{
|
|
Id: "tryAutodiscoverPost",
|
|
Type: "bool",
|
|
Label: "Probe Microsoft Autodiscover (POST)",
|
|
Default: true,
|
|
Description: "Exercise Exchange/Outlook Autodiscover endpoints as well.",
|
|
},
|
|
}
|
|
}
|
|
|
|
// ParseForm turns a submitted /check form into the CheckerOptions the
|
|
// Collect step expects. Collect itself handles all DNS/HTTP probing, so
|
|
// there is nothing to resolve up-front here beyond accepting the domain.
|
|
func (p *autoconfigProvider) ParseForm(r *http.Request) (sdk.CheckerOptions, error) {
|
|
domain := strings.TrimSuffix(strings.TrimSpace(r.FormValue(sdk.AutoFillDomainName)), ".")
|
|
if domain == "" {
|
|
return nil, errors.New("domain name is required")
|
|
}
|
|
|
|
opts := sdk.CheckerOptions{
|
|
sdk.AutoFillDomainName: domain,
|
|
}
|
|
if v := strings.TrimSpace(r.FormValue("probeEmail")); v != "" {
|
|
opts["probeEmail"] = v
|
|
}
|
|
opts["tryISPDB"] = r.FormValue("tryISPDB") == "true"
|
|
opts["tryHTTPAutoconfig"] = r.FormValue("tryHTTPAutoconfig") == "true"
|
|
opts["tryAutodiscoverPost"] = r.FormValue("tryAutodiscoverPost") == "true"
|
|
|
|
return opts, nil
|
|
}
|