likexian / whois

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

Failure performing query when `Registrar WHOIS Server` line in WHOIS record has `http://` #28

Closed atc0005 closed 1 year ago

atc0005 commented 1 year ago

Hi,

First of all, many thanks for this useful library. I've used it and the whois-parse library in a Nagios plugin to monitor the expiration date of WHOIS registrations.

I recently had a user of the plugin report an issue with monitoring the expiration for a specific domain. After troubleshooting, I found that this error message:

dial tcp: address tcp///whois.pairdomains.com: unknown port

is related to this line:

Registrar WHOIS Server: http://whois.pairdomains.com

If we override the WHOIS server used by explicitly specifying the whois server as whois.iana.org (which seems to be the default), the error is not encountered. This seems to be because of this code path:

https://github.com/likexian/whois/blob/a48608e6097ab07def16344e5821c03529cb472a/whois.go#L122-L124

Here the port is explicitly set to the default, ignoring any potential port specified in the Registrar WHOIS Server line.

If we don't explicitly specify the whois server, then this path is taken:

https://github.com/likexian/whois/blob/a48608e6097ab07def16344e5821c03529cb472a/whois.go#L125-L134

and in the getServer function this logic is applied:

https://github.com/likexian/whois/blob/a48608e6097ab07def16344e5821c03529cb472a/whois.go#L235-L239

atc0005 commented 1 year ago

I've looked into it, but I can't find enough information to confirm the specific format requirements for the WHOIS server in the Registrar WHOIS Server line.

These references seem to suggest that the expected format is to omit http:// (and any other protocol):

Based on that information and the examples I've found/reviewed thus far, it looks like the record I encountered with this line:

Registrar WHOIS Server: http://whois.pairdomains.com

should be updated to remove the http:// prefix.

Would you be willing to update this library to handle removing any leading protocol scheme and :// characters before attempting to locate a custom port in the Registrar WHOIS Server line?

atc0005 commented 1 year ago

Would you be willing to update this library to handle removing any leading protocol scheme and :// characters before attempting to locate a custom port in the Registrar WHOIS Server line?

I looked closer and found that the leading protocol scheme and :// characters are already being removed. I compared against current master branch and saw that this is already fixed by #26.

Are you open to creating a new tag for a48608e6097ab07def16344e5821c03529cb472a?

likexian commented 1 year ago

Hello @atc0005 Thanks for your feedback, please use tag v1.14.3


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