GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Why Go
  • Case Studies
  • Use Cases
  • Security
  • Learn
  • Effective Go
  • Go User Manual
  • Standard library
  • Release Notes
  • API
  • Packages
  • Recorded Talks
  • Meetups
  • Conferences

This view

  • Original page
  • New address

GeezerVison is showing pkg.go.dev — available package - github.com/haccer/available - Go Packages

Details

  • checked Valid go.mod file

    The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.

  • checked Redistributable license

    Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.

  • checked Tagged version

    Modules with tagged versions give importers more predictable builds.

  • checked Stable version

    When a project reaches major version v1 it is considered stable.

  • Learn more about best practices

Repository

github.com/haccer/available

Links

  • Open Source Insights Logo Open Source Insights

README ¶

Is 'domain.x' Available?

CI Go Report Card GoDoc GitHub license

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
  • func Domain(domain string) bool
  • func DomainTimeout(domain string, timeout time.Duration) bool
  • func SafeDomain(domain string) (available, badtld bool)
  • func SafeDomainTimeout(domain string, timeout time.Duration) (available, badtld bool)

Constants ¶

View Source
const DefaultTimeout = 10 * time.Second

DefaultTimeout is the timeout used by Domain and SafeDomain.

Variables ¶

This section is empty.

Functions ¶

func Domain ¶

func Domain(domain string) bool

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 ¶

func DomainTimeout(domain string, timeout time.Duration) bool

DomainTimeout is Domain with a caller-supplied timeout.

func SafeDomain ¶

func SafeDomain(domain string) (available, badtld bool)
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.

func SafeDomainTimeout ¶

func SafeDomainTimeout(domain string, timeout time.Duration) (available, badtld bool)

SafeDomainTimeout is SafeDomain with a caller-supplied timeout.

Types ¶

This section is empty.

Source Files ¶

View all Source files
  • bad.go
  • check.go
  • rdap.go
  • whois.go
Click to show internal directories.
Click to hide internal directories.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.