Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
atc0005 opened this issue Nov 8, 2022 · 3 comments

Comments

@atc0005
Copy link

atc0005 commented Nov 8, 2022

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:

whois/whois.go

Lines 122 to 124 in a48608e

if len(servers) > 0 && servers[0] != "" {
server = strings.ToLower(servers[0])
port = defaultWhoisPort

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:

whois/whois.go

Lines 125 to 134 in a48608e

} else {
ext := getExtension(domain)
result, err := c.rawQuery(ext, defaultWhoisServer, defaultWhoisPort)
if err != nil {
return "", fmt.Errorf("whois: query for whois server failed: %w", err)
}
server, port = getServer(result)
if server == "" {
return "", fmt.Errorf("%w: %s", ErrWhoisServerNotFound, domain)
}

and in the getServer function this logic is applied:

whois/whois.go

Lines 235 to 239 in a48608e

if strings.Contains(server, ":") {
v := strings.Split(server, ":")
server, port = v[0], v[1]
}
return server, port

@atc0005
Copy link
Author

atc0005 commented Nov 8, 2022

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
Copy link
Author

atc0005 commented Nov 8, 2022

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 a48608e?

@likexian
Copy link
Owner

likexian commented Nov 9, 2022

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.

@likexian likexian closed this as completed Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants