domain

package module
v0.0.0-...-c613241 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2021 License: MIT Imports: 7 Imported by: 1

README

domain

domain name availability check using WHOIS protocol.

Install

go get github.com/twiny/domain

Example

func main() {
	// using default dialer
	d := net.Dialer{Timeout: 30 * time.Second}

	// // using socks5 dialer
	// d, err := proxy.SOCKS5("tcp", "118.70.179.208:1080", nil, proxy.Direct)
	// if err != nil {
	// 	fmt.Println(err)
	// 	return
	// }

	status, err := domain.AvailableCheck("MyNewDomainExample.com", d.Dial)
	fmt.Println(status, err)

	fmt.Println("done")
}

How it works?

The first thing to check is if the domain has a valid syntax. a valid domain name is an alphanumeric string with hyphens (-), below condition must apply: - starts/end with number or letter. - no consecutive hyphen.

Then, NS Check, assuming all available domains have no Nameserver DNS (NS record).

Last, if the above conditions are passed, check whois DNS by dialing the corresponded WHOIS server, if the domain has no records in the WHOIS database then we assume the domain is available.

WHOIS server

Big thanks to @neonbunny https://github.com/nccgroup/typofinder/blob/master/TypoMagic/datasources/whois-servers.txt

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//
	ErrBadSyntax         = errors.New("Invalid domain syntax")
	ErrHasNS             = errors.New("Domain already has NS")
	ErrWhoisNotFound     = errors.New("WHOIS server not found")
	ErrConnectionFailed  = errors.New("TCP connection failure")
	ErrConnectionWrite   = errors.New("Error writting to connection")
	ErrAlreadyRegistered = errors.New("Domain already registered")
)
View Source
var TLDs = map[string]*record{}/* 122 elements not displayed */

TLDs list

Functions

func AvailableCheck

func AvailableCheck(domain string, d Dialer) (bool, error)

AvailableCheck func

Types

type Dialer

type Dialer func(network, address string) (net.Conn, error)

Dialer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL