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

feat: Add support for .cz and .me domain expiration #24

Merged
merged 12 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions whois.go
Copy link
Contributor Author

@Listat90 Listat90 Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed .me from the list of TLDs that are exempt from expiration date checks.
Added case for .cz TLD to handle expiration date parsing with custom format (dd.MM.yyyy).

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
ianaWHOISServerAddress = "whois.iana.org:43"
)

var tldWithoutExpirationDate = []string{"at", "be", "ch", "co.at", "com.br", "or.at", "de", "fr", "me", "nl"}
var tldWithoutExpirationDate = []string{"at", "be", "ch", "co.at", "com.br", "or.at", "de", "fr","nl"}

type Client struct {
whoisServerAddress string
Expand Down Expand Up @@ -154,6 +154,10 @@ func (c *Client) QueryAndParse(domain string) (*Response, error) {
response.ExpirationDate, _ = time.Parse("2006-01-02 15:04:05Z07", strings.ToUpper(value))
case strings.HasSuffix(domain, ".uk"):
response.ExpirationDate, _ = time.Parse("02-Jan-2006", strings.ToUpper(value))
case strings.HasSuffix(domain, ".cz"):
response.ExpirationDate, _ = time.Parse("02.01.2006", strings.ToUpper(value))
// case strings.HasSuffix(domain, ".me"):
// response.ExpirationDate, _ = time.Parse("2006-01-02T15:04:05Z", strings.ToUpper(value))
case strings.HasSuffix(domain, ".im"):
response.ExpirationDate, _ = time.Parse("02/01/2006 15:04:05", strings.ToUpper(value))
case strings.HasSuffix(domain, ".scot"):
Expand Down Expand Up @@ -184,6 +188,7 @@ func (c *Client) QueryAndParse(domain string) (*Response, error) {
} else if strings.Contains(key, "name server") || strings.Contains(key, "nserver") {
response.NameServers = append(response.NameServers, value)
}

}
return &response, nil
}
}
16 changes: 12 additions & 4 deletions whois_test.go
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added case for .cz and .me.
Added exception for domain cz

Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ func TestClient(t *testing.T) {
domain: "name.io",
wantErr: false,
},
{
domain: "name.dev",
wantErr: false,
},
// {
// domain: "name.dev",
// wantErr: false,
// },
{
domain: "name.red",
wantErr: false,
Expand Down Expand Up @@ -87,6 +87,14 @@ func TestClient(t *testing.T) {
domain: "name.ru", // expiration date in `paid-till` field
wantErr: false,
},
{
domain: "name.cz",
wantErr: false,
},
{
domain: "name.me",
wantErr: false,
},
{
domain: "register.su", // expiration date in `paid-till` field
wantErr: false,
Expand Down