Skip to content

Commit

Permalink
init 1
Browse files Browse the repository at this point in the history
  • Loading branch information
dwisiswant0 committed Feb 20, 2022
0 parents commit 5070c81
Show file tree
Hide file tree
Showing 27 changed files with 2,099 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: ["https://paypal.me/dw1s", "https://saweria.co/dwisiswant0"]
23 changes: 23 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build
on:
push:
branches:
- master
pull_request:

jobs:
build:
name: Dependencies
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Check out code
uses: actions/checkout@v2

- name: Build
run: go build .
working-directory: ./
27 changes: 27 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release
on:
create:
tags:
- v*

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: "Check out code"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "Set up Go"
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: "Create release on GitHub"
uses: goreleaser/goreleaser-action@v2
with:
args: "release --rm-dist"
version: latest
env:
GITHUB_TOKEN: "${{ secrets.RELEASE_TOKEN }}"
43 changes: 43 additions & 0 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update DB
on:
schedule:
- cron: "0 0 * * 0" # at 00:00 on Sunday
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: "Install dependencies"
run: sudo apt install curl -y

- name: "Check for updates"
run: |
if [[ "$(curl -skL ${{ secrets.LOCAL_DB }} | wc -l)" == "$(curl -skL ${{ secrets.REMOTE_DB }} | wc -l)" ]]; then
echo "::set-output name=isUpdated::true"
else
echo "::set-output name=isUpdated::false"
fi
echo "::set-output name=date::$(date)"
- name: "Check out code"
if: steps.check.isUpdated == 'false'
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "Update DB..."
run: curl -kLo db/tlds.txt ${{ secrets.REMOTE_DB }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
body: "Automated update TLDs data."
branch-suffix: "short-commit-hash"
branch: "update/db"
commit-message: "db: Update DB ${{ steps.check.date }}"
committer: "Dwi Siswanto <me@dw1.io>"
delete-branch: true
reviewers: "dwisiswant0"
title: "db: Update DB ${{ steps.check.date }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tlder
21 changes: 21 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
builds:
- binary: tlder
main: .
goos:
- linux
- windows
- darwin
goarch:
- amd64
- 386
- arm
- arm64

archives:
- id: tgz
format: tar.gz
replacements:
darwin: macOS
format_overrides:
- goos: windows
format: zip
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Dwi Siswanto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# TLD:er

TLDs finder — check domain name availability across all valid top-level domains.

## Installation

- Get pre-built binary from [releases page](https://github.com/dwisiswant0/tlder/releases), or
- If you have [Go1.17+](https://go.dev/dl/) compiler installed & configured: `go install github.com/dwisiswant0/tlder@latest`.

## Usage

```console
> tlder -h
________ ___
/_ __/ / / _ \___ ____
/ / / /_/ // / -_) __/
/_/ /___/____/\__/_/
---
@dwisiswant0


Usage:
tlder -d NAME

Options:
-d, --domain <NAME> Domain NAME to permutate
-s, --silent Silent mode
--unreg Show unregistered TLDs only
```

## Data

TLDs data taken from [data.iana.org](https://data.iana.org/TLD/). Checks for data updates are carried out weekly by [GitHub workflow](https://github.com/dwisiswant0/tlder/actions/workflows/update.yaml).

## Library

You can use **TLDer** as library. For example:

```go
package main

import "github.com/dwisiswant0/tlder"

func main() {
name := "dw1"
ext := "io"

avail, err := tlder.IsAvailable(name, ext)
if err != nil {
panic(err)
}

print(avail)
}
```

## License

**tlder** is distributed under MIT, contributions are welcome! See `LICENSE`.
35 changes: 35 additions & 0 deletions availability.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"strings"

"github.com/dwisiswant0/tlder/fingerprint"
)

// IsAvailable domain check from whois response with predefined fingerprint
func IsAvailable(domain string, extension string) (bool, error) {
var s bool

resp, err := whoIs(domain, extension)
if err != nil {
return s, err
}

if len([]byte(resp)) == 0 {
return s, errNoResponses
}

if strings.Contains(resp, "RATE LIMIT EXCEEDED") {
return s, errRateLimited
}

a := sliceContains(strings.ToLower(resp), fingerprint.Available)
u := sliceContains(resp, fingerprint.Unregistered)
// r := sliceContains(resp, fingerprint.Registered)

if a || u {
return !s, nil
}

return s, nil
}
18 changes: 18 additions & 0 deletions consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

const (
banner = `
________ ___
/_ __/ / / _ \___ ____
/ / / /_/ // / -_) __/
/_/ /___/____/\__/_/ `
author = "@dwisiswant0"
usage = `
Usage:
tlder -d NAME
Options:
-d, --domain <NAME> Domain NAME to permutate
-s, --silent Silent mode
--unreg Show unregistered TLDs only`
)
8 changes: 8 additions & 0 deletions db/db.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package db

import "strings"

func init() {
List = strings.Split(tlds, "\n")
List = List[1 : len(List)-1]
}
Loading

0 comments on commit 5070c81

Please sign in to comment.