mirror of
https://github.com/idanoo/go-domain-checker
synced 2025-07-01 05:32:16 +00:00
Check 2chars
This commit is contained in:
parent
6258a39050
commit
9000f70940
3 changed files with 92 additions and 0 deletions
11
go.mod
Normal file
11
go.mod
Normal file
|
@ -0,0 +1,11 @@
|
|||
module godomainchecker
|
||||
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/likexian/gokit v0.25.6 // indirect
|
||||
github.com/likexian/whois v1.12.4 // indirect
|
||||
github.com/likexian/whois-parser v1.22.0 // indirect
|
||||
golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6 // indirect
|
||||
golang.org/x/text v0.3.6 // indirect
|
||||
)
|
11
go.sum
Normal file
11
go.sum
Normal file
|
@ -0,0 +1,11 @@
|
|||
github.com/likexian/gokit v0.25.6 h1:DZuMrmfgXErhdfI9SIS6tVMZ5QbRMP3aruHNq5lGcMI=
|
||||
github.com/likexian/gokit v0.25.6/go.mod h1:q1LC+z3cBymJuE4oeiWiIPhJceUa0nptg4Id8tSzjZI=
|
||||
github.com/likexian/whois v1.12.4 h1:NqUNc9LC4G5Fq62o6a3nw/HO8haJDULEudcJPyPMwXg=
|
||||
github.com/likexian/whois v1.12.4/go.mod h1:SfdfmB72mSdrC/8eLjYkeaEJp9t1MPAgp0ebCzZfYXw=
|
||||
github.com/likexian/whois-parser v1.22.0 h1:YXSNvDNBy+cZG+2JZWJvWbMHrDY35r6Etpu1TNDPYW0=
|
||||
github.com/likexian/whois-parser v1.22.0/go.mod h1:2bJqtH4tNPanBvOp/3Kj3Sd12S9vxTbsJ0+0zjRc3ow=
|
||||
golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6 h1:Z04ewVs7JhXaYkmDhBERPi41gnltfQpMWDnTnQbaCqk=
|
||||
golang.org/x/net v0.0.0-20210929193557-e81a3d93ecf6/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
70
main.go
Normal file
70
main.go
Normal file
|
@ -0,0 +1,70 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/likexian/whois"
|
||||
"github.com/likexian/whois-parser"
|
||||
)
|
||||
|
||||
func main() {
|
||||
freeDomains := []string{}
|
||||
|
||||
domainsToCheck := generateInput()
|
||||
|
||||
for _, domain := range domainsToCheck {
|
||||
resp, err := checkDomain(domain)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if resp {
|
||||
log.Printf("%s is free!", domain)
|
||||
freeDomains = append(freeDomains, domain)
|
||||
} else {
|
||||
log.Printf("%s is not free!", domain)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println()
|
||||
log.Println("Free Domains:")
|
||||
|
||||
for _, v := range freeDomains {
|
||||
log.Print(v)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// checkDomain - True if available, error/false if not
|
||||
func checkDomain(domain string) (bool, error) {
|
||||
time.Sleep(time.Second * 5)
|
||||
resultRaw, err := whois.Whois(domain, "whois.srs.net.nz")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
_, err = whoisparser.Parse(resultRaw)
|
||||
if err != nil {
|
||||
if err.Error() == "whoisparser: domain is not found" {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, err
|
||||
}
|
||||
|
||||
return false, err
|
||||
}
|
||||
|
||||
func generateInput() []string {
|
||||
output := []string{}
|
||||
|
||||
for o := 'a'; o <= 'z'; o++ {
|
||||
for r := 'a'; r <= 'z'; r++ {
|
||||
output = append(output, fmt.Sprintf("%c", o)+fmt.Sprintf("%c", r))
|
||||
}
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue