From b313b827c804e7b232a35ec4cb543648c4e72b2c Mon Sep 17 00:00:00 2001 From: TwiN Date: Thu, 17 Nov 2022 21:46:20 -0500 Subject: [PATCH 01/11] ci: Remove open-pull-requests-limit parameter --- .github/dependabot.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index aec7462..b016134 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,7 +2,6 @@ version: 2 updates: - package-ecosystem: "gomod" directory: "/" - open-pull-requests-limit: 1 schedule: interval: "weekly" day: "monday" From 406ff44c8f98691d01e8539d9df033270f797c99 Mon Sep 17 00:00:00 2001 From: TwiN Date: Mon, 21 Nov 2022 19:07:46 -0500 Subject: [PATCH 02/11] docs: Clarify that you must unzip the file from the release section Fixes #4 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 59859c1..9120ec9 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ To install it: ```console go install github.com/TwiN/whois/cmd/whois@latest ``` +Alternatively, you can download whois from the [release](https://github.com/TwiN/whois/releases) section, though you'll have to unzip the file first. + To run it: ```console whois example.com From c4b6a43499659c952edb714005f62a903790c42b Mon Sep 17 00:00:00 2001 From: TwiN Date: Tue, 22 Nov 2022 19:14:07 -0500 Subject: [PATCH 03/11] chore: Rename test.yaml to test.yml --- .github/workflows/{test.yaml => test.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{test.yaml => test.yml} (100%) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yml similarity index 100% rename from .github/workflows/test.yaml rename to .github/workflows/test.yml From 5562fedfab3912dace96d99db415ec51b339b16f Mon Sep 17 00:00:00 2001 From: TwiN Date: Tue, 22 Nov 2022 19:14:20 -0500 Subject: [PATCH 04/11] chore: Rename whois.go to main.go --- cmd/whois/{whois.go => main.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cmd/whois/{whois.go => main.go} (100%) diff --git a/cmd/whois/whois.go b/cmd/whois/main.go similarity index 100% rename from cmd/whois/whois.go rename to cmd/whois/main.go From d5ce6ead01906a5fe469e46f96eb756a11a6dd0b Mon Sep 17 00:00:00 2001 From: TwiN Date: Tue, 22 Nov 2022 19:15:30 -0500 Subject: [PATCH 05/11] build: Fix path in build script Fixes #4 --- scripts/build.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 3ab0206..cc6fb8d 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -9,22 +9,22 @@ APPLICATION_NAME="whois" mkdir bin rm -rf bin/${APPLICATION_NAME}-*.zip -env GOOS=darwin GOARCH=amd64 go build -mod vendor -o ${APPLICATION_NAME} +env GOOS=darwin GOARCH=amd64 go build -o ${APPLICATION_NAME} ./cmd/whois/main.go chmod +x ${APPLICATION_NAME} zip bin/${APPLICATION_NAME}-darwin-amd64.zip ${APPLICATION_NAME} -m -env GOOS=darwin GOARCH=arm64 go build -mod vendor -o ${APPLICATION_NAME} +env GOOS=darwin GOARCH=arm64 go build -o ${APPLICATION_NAME} ./cmd/whois/main.go chmod +x ${APPLICATION_NAME} zip bin/${APPLICATION_NAME}-darwin-arm64.zip ${APPLICATION_NAME} -m -env GOOS=linux GOARCH=amd64 go build -mod vendor -o ${APPLICATION_NAME} +env GOOS=linux GOARCH=amd64 go build -o ${APPLICATION_NAME} ./cmd/whois/main.go chmod +x ${APPLICATION_NAME} zip bin/${APPLICATION_NAME}-linux-amd64.zip ${APPLICATION_NAME} -m -env GOOS=linux GOARCH=arm64 go build -mod vendor -o ${APPLICATION_NAME} +env GOOS=linux GOARCH=arm64 go build -o ${APPLICATION_NAME} ./cmd/whois/main.go chmod +x ${APPLICATION_NAME} zip bin/${APPLICATION_NAME}-linux-arm64.zip ${APPLICATION_NAME} -m -env GOOS=windows GOARCH=amd64 go build -mod vendor -o ${APPLICATION_NAME}.exe +env GOOS=windows GOARCH=amd64 go build -o ${APPLICATION_NAME}.exe ./cmd/whois/main.go chmod +x ${APPLICATION_NAME}.exe zip bin/${APPLICATION_NAME}-windows-amd64.zip ${APPLICATION_NAME}.exe -m From d99a696a151b3dc0558e90d4d7f48c97c05f66c3 Mon Sep 17 00:00:00 2001 From: TwiN Date: Tue, 22 Nov 2022 19:17:18 -0500 Subject: [PATCH 06/11] chore: Add .gitattributes --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..94f480d --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf \ No newline at end of file From 7641c264d52a44b7b8bc79083c798310d29c4550 Mon Sep 17 00:00:00 2001 From: TwiN Date: Mon, 13 Feb 2023 19:47:38 -0500 Subject: [PATCH 07/11] chore: Upgrade Go to 1.20 --- .github/workflows/test.yml | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59b4298..1a20203 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,6 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: 1.20 - uses: actions/checkout@v3 - run: go test ./... --cover diff --git a/go.mod b/go.mod index 8da833f..6b5cb26 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/TwiN/whois -go 1.19 +go 1.20 From 9b6d29f03622f944f43d6292b402753e6a3eb09f Mon Sep 17 00:00:00 2001 From: TwiN Date: Mon, 13 Feb 2023 19:53:08 -0500 Subject: [PATCH 08/11] ci: Use Go 1.19 for test because 1.20 doesn't appear to be available yet --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1a20203..59b4298 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,6 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.20 + go-version: 1.19 - uses: actions/checkout@v3 - run: go test ./... --cover From ae1888c86ab030f5b5f1e9b9b1fbe6308df3d4ea Mon Sep 17 00:00:00 2001 From: TwiN Date: Tue, 21 Feb 2023 19:04:41 -0500 Subject: [PATCH 09/11] legal: Bump license year --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index ea31ca1..5730e0c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 TwiN +Copyright (c) 2022-2023 TwiN Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From c0a275da3e61be3c0dadff019ac619467c17b733 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 26 Mar 2023 16:34:00 -0400 Subject: [PATCH 10/11] build(deps): Bump actions/setup-go from 3 to 4 (#5) Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59b4298..65d66cd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 3 steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: 1.19 - uses: actions/checkout@v3 From ea4c6db71c1ce21647095a55c87846fc73a1065e Mon Sep 17 00:00:00 2001 From: Julian Pieles Date: Sat, 3 Jun 2023 02:27:06 +0200 Subject: [PATCH 11/11] return error for all domain exts without grace period (#6) * return error for all domain exts without grace period * Update whois.go * requested changes --------- Co-authored-by: julian.pieles Co-authored-by: TwiN --- whois.go | 18 +++++++++++++++++- whois_test.go | 40 ++++++++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/whois.go b/whois.go index 90d8f3b..86e2ea6 100644 --- a/whois.go +++ b/whois.go @@ -1,6 +1,7 @@ package whois import ( + "errors" "io" "net" "strings" @@ -11,6 +12,8 @@ const ( ianaWHOISServerAddress = "whois.iana.org:43" ) +var tldWithoutExpirationDate = []string{"at","be","ch","co.at","com.br","or.at","de","fr","me","mx","nl"} + type Client struct { whoisServerAddress string @@ -49,14 +52,27 @@ func (c *Client) WithReferralCache(enabled bool) *Client { return c } +func doesTLDHaveExpirationDate(e string) bool { + for _, a := range tldWithoutExpirationDate { + if a == e { + return true + } + } + return false +} + func (c *Client) Query(domain string) (string, error) { parts := strings.Split(domain, ".") + domainExtension := parts[len(parts)-1] + if doesTLDHaveExpirationDate(domainExtension) { + return "", errors.New("Domain extension " + domainExtension + " does not have a grace period.") + } if c.isCachingReferralWHOISServers { if cachedWHOISServer, ok := c.referralWHOISServersCache[domain]; ok { return c.query(cachedWHOISServer, domain) } } - output, err := c.query(c.whoisServerAddress, parts[len(parts)-1]) + output, err := c.query(c.whoisServerAddress, domainExtension) if err != nil { return "", err } diff --git a/whois_test.go b/whois_test.go index 0c7ebf2..1e9f778 100644 --- a/whois_test.go +++ b/whois_test.go @@ -47,6 +47,10 @@ func TestClient(t *testing.T) { domain: "name.black", wantErr: false, }, + { + domain: "name.de", + wantErr: true, + }, } client := NewClient().WithReferralCache(true) for _, scenario := range scenarios { @@ -56,11 +60,13 @@ func TestClient(t *testing.T) { t.Error("expected error, got none") t.FailNow() } - if !scenario.wantErr && err != nil { - t.Error("expected no error, got", err.Error()) - } - if !strings.Contains(strings.ToLower(output), scenario.domain) { - t.Errorf("expected %s in output, got %s", scenario.domain, output) + if !scenario.wantErr { + if err != nil { + t.Error("expected no error, got", err.Error()) + } + if !strings.Contains(strings.ToLower(output), scenario.domain) { + t.Errorf("expected %s in output, got %s", scenario.domain, output) + } } }) time.Sleep(50 * time.Millisecond) // Give the WHOIS servers some breathing room @@ -70,17 +76,19 @@ func TestClient(t *testing.T) { t.Error("expected error, got none") t.FailNow() } - if !scenario.wantErr && err != nil { - t.Error("expected no error, got", err.Error()) - } - if response.ExpirationDate.Unix() == 0 { - t.Errorf("expected to have an expiry date") - } - if len(response.NameServers) == 0 { - t.Errorf("expected to have at least one name server") - } - if len(response.DomainStatuses) == 0 { - t.Errorf("expected to have at least one domain status") + if !scenario.wantErr { + if err != nil { + t.Error("expected no error, got", err.Error()) + } + if response.ExpirationDate.Unix() == 0 { + t.Errorf("expected to have an expiry date") + } + if len(response.NameServers) == 0 { + t.Errorf("expected to have at least one name server") + } + if len(response.DomainStatuses) == 0 { + t.Errorf("expected to have at least one domain status") + } } }) time.Sleep(50 * time.Millisecond) // Give the WHOIS servers some breathing room