Initial commit
This commit is contained in:
commit
eea7e4e459
22 changed files with 2520 additions and 0 deletions
49
checker/interactive.go
Normal file
49
checker/interactive.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//go:build standalone
|
||||
|
||||
package checker
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||
)
|
||||
|
||||
func (p *aliasProvider) RenderForm() []sdk.CheckerOptionField {
|
||||
return []sdk.CheckerOptionField{
|
||||
{
|
||||
Id: "name",
|
||||
Type: "string",
|
||||
Label: "Domain name to check",
|
||||
Placeholder: "alias.example.com",
|
||||
Required: true,
|
||||
Description: "Fully-qualified name carrying (or suspected of carrying) a CNAME / DNAME / ALIAS record.",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p *aliasProvider) ParseForm(r *http.Request) (sdk.CheckerOptions, error) {
|
||||
name := strings.TrimSpace(r.FormValue("name"))
|
||||
if name == "" {
|
||||
return nil, errors.New("name is required")
|
||||
}
|
||||
name = strings.TrimSuffix(name, ".")
|
||||
|
||||
// Split into subdomain + domain_name so rules autoscoping on domain_name
|
||||
// still work; the collector accepts either representation.
|
||||
parts := strings.SplitN(name, ".", 2)
|
||||
sub := parts[0]
|
||||
parent := ""
|
||||
if len(parts) == 2 {
|
||||
parent = parts[1]
|
||||
} else {
|
||||
parent = name
|
||||
sub = ""
|
||||
}
|
||||
|
||||
return sdk.CheckerOptions{
|
||||
"domain_name": parent,
|
||||
"subdomain": sub,
|
||||
}, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue