haccer / available

Domain availability checking for Golang
GNU General Public License v3.0
45 stars 13 forks source link

twitch.tv markes as available #5

Open PatchRequest opened 10 months ago

PatchRequest commented 10 months ago

Hi, when i run the following code:

package main

import (
    "fmt"

    "github.com/haccer/available"
)

func main() {
    fmt.Println(available.Domain("twitch.tv"))
}

It return true, which is obviously wrong.

How can we fix this? :D

PatchRequest commented 10 months ago

I looked into it a little an it looks like the response from the whois lib is No match for "TWITCH.TV". Weird

haccer commented 10 months ago

Hi @CementryMage - I'm looking into this

haccer commented 10 months ago

It looks like this is an issue with https://github.com/domainr/whois, which I use to make whois requests. All .tv is appearing to be available:

% go run test.go
true
No match for "APPLE.TV".

I've fixed the issue to use whois.nic.tv as the whois server:

func getWhois(tld string, domain string) (response string) {
    req, err := whois.NewRequest(domain)
    if err != nil {
        return
    }

    if tld == "tv" {
        req.Host = "whois.nic.tv"
        req.Body = []byte(fmt.Sprintf("%s\r\n", req.Query))
    }

    resp, err := whois.DefaultClient.Fetch(req)
    if err != nil {
        return
    }

    return fmt.Sprintf("%s", resp)
}

Thank you for reporting this issue!

PatchRequest commented 9 months ago

Thanks for the fix!

PatchRequest commented 9 months ago

i did not dig deeper but i saw similar behavior with .ca and .lt if i remember it correctly

haccer commented 9 months ago

Thanks for the letting me know @PatchRequest, I'm going to reopen this issue then.

I'll begin updating available and going through each TLD to make sure all the whois servers are correct.