README
¶
Is 'domain.x' Available?
IN RDAP WE TRUST
My cheap way of checking whether a domain is available to be purchased or not.
Availability is checked with RDAP first (RFC 9083): the answer is carried by the HTTP status itself — 404 means the domain is not registered, 200 means it is. RDAP servers are discovered from the IANA bootstrap file and cached per TLD, so there is no per-TLD configuration to maintain and no registry response text to fingerprint. TLDs without RDAP fall back to a small whois client (RFC 3912) that discovers authoritative servers via IANA referral and matches a short list of generic "available" responses.
The only dependency is golang.org/x/net (for public suffix data).
Disclaimer
This package might not be able to check the availability of every possible domain TLD. Always double-check results manually before acting on them.
Usage
package main
import (
"fmt"
"time"
"github.com/haccer/available"
)
func main() {
// Domain uses a 10s timeout.
if available.Domain("dreamdomain.io") {
fmt.Println("[+] Success!")
}
// ...or supply your own timeout.
available.DomainTimeout("dreamdomain.io", 5*time.Second)
// SafeDomain also reports whether the TLD has no usable whois/RDAP
// server ("bad" TLD), so you can skip or flag it.
avail, badTLD := available.SafeDomain("dreamdomain.io")
fmt.Println(avail, badTLD)
}
All functions are safe for concurrent use: subdomains are reduced to their registrable domain (eTLD+1) first, and the bootstrap data and whois servers are resolved once per TLD and cached.
Tests
The test suite runs entirely offline against local RDAP and whois fixtures:
go test -race ./...
Documentation
¶
Index ¶
Constants ¶
const DefaultTimeout = 10 * time.Second
DefaultTimeout is the timeout used by Domain and SafeDomain.
Variables ¶
This section is empty.
Functions ¶
func Domain ¶
Domain reports whether the registrable domain under domain is unregistered. Any subdomain is reduced to its eTLD+1 first, so Domain("sub.example.com") checks "example.com".
RDAP (RFC 9083) is consulted first: an authoritative 404 means the domain is not registered. TLDs without RDAP (and failed lookups) fall back to parsing a legacy whois response.
func DomainTimeout ¶
DomainTimeout is Domain with a caller-supplied timeout.
func SafeDomain ¶
SafeDomain utilizes the badtld checklist as a triage step,
then returns whether the domain is available and/or if the domain has a "bad" tld.
Types ¶
This section is empty.