Package dns

Domain normalization, syntax validation, and DNS pre-flight resolution checks. Source: internal/dns/dns.go.


NormalizeDomain

func NormalizeDomain(d string) string

Lowercases the input and strips scheme, path, port, and trailing dot. Mirrors the shell normalize_domain helper.

dns.NormalizeDomain("HTTPS://Example.COM:8443/path")
// => "example.com"

ValidSyntax

func ValidSyntax(d string) bool

Reports whether d looks like a dotted domain name: labels of alphanumerics and hyphens with at least one dot. Used to reject malformed input before any network call.

dns.ValidSyntax("jdsoft.com")  // => true
dns.ValidSyntax("no-dot")      // => false

CheckDNS

func CheckDNS(ctx context.Context, domain string, timeout time.Duration) error

Aborts early on NXDOMAIN or unresolvable names via net.DefaultResolver.LookupIP with the given deadline. Returns nil when at least one IPv4 address resolves, an error otherwise.

ParameterDescription
ctxParent context; the global 15 second budget.
domainAlready-normalized domain to resolve.
timeoutPer-call deadline (the CLI --timeout value).