likexian / whois

Whois client for domain and ip whois information query in Go(Golang).
Apache License 2.0
382 stars 70 forks source link

Add query ASN Support #15

Closed steveyiyo closed 3 years ago

steveyiyo commented 3 years ago

Hello,

I am a beginner for Golang.

I'm happy you make this project! And I found a problem. It does not support queries for ASN.

If whois query for ASN, It should recursive query, but it didn't do it.

So I add a code to check if it is ASN. Please check it.

if !strings.Contains(domain, "as") && !strings.Contains(domain, "AS") {
    if !strings.Contains(domain, ".") && !strings.Contains(domain, ":") {
        checkASN := strings.Replace(strings.ToUpper(domain), "AS", "", -1)
        _, err := strconv.ParseFloat(checkASN, 64)
        if err != nil {
            return query(domain, IANA_WHOIS_SERVER)
        }
    }
}

Thank You!

likexian commented 3 years ago

Hello @steveyiyo Thanks for your PR.