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) error |
Aborts early on NXDOMAIN or unresolvable names via
net.DefaultResolver.LookupIP with a 5 second deadline. Returns
nil when at least one IPv4 address resolves, an error otherwise.
| Parameter | Description |
| ctx | Parent context; the global 15 second budget. |
| domain | Already-normalized domain to resolve. |