likexian / whois

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

handle ReferralServer #23

Closed quite closed 2 years ago

quite commented 2 years ago

whois for 144.200.46.16 contains a ReferralServer, a token which should be handled. A naive fix follows below. But, the result of it is that whois data from both the referring and the referred server is output. I'm not sure that it should? Perhaps only the latter should be output?

diff --git a/whois.go b/whois.go
index efd763f..762ca79 100644
--- a/whois.go
+++ b/whois.go
@@ -217,6 +217,7 @@ func getServer(data string) string {
    tokens := []string{
        "Registrar WHOIS Server: ",
        "whois: ",
+       "ReferralServer: ",
    }

    for _, token := range tokens {
@@ -226,6 +227,7 @@ func getServer(data string) string {
            end := strings.Index(data[start:], "\n")
            server := strings.TrimSpace(data[start : start+end])
            server = strings.Trim(server, "/")
+           server = strings.TrimPrefix(server, "whois://")
            return server
        }
    }
quite commented 2 years ago

Just saw whois 172.109.217.241 which has ReferralServer: rwhois://rwhois.frontiernet.net:4321. Potential rabbit hole here ;)

likexian commented 2 years ago

Hello @quite Thanks for your feedback, let me see see.

likexian commented 2 years ago

Hello @quite This has been fixed, please try the latest version.


If you think this repository is helpful, please share it with friends, thanks.