Domain Checker Tool
November 26, 2024 ยท View on GitHub
A high-performance Go-based tool for checking the availability and responsiveness of domains, utilizing both HTTP requests and browser automation for comprehensive analysis.
Features
- Concurrent Domain Checking: Utilizes Go's goroutines to check multiple domains in parallel.
- DNS Resolution: Verifies if the domain can be resolved via DNS.
- HTTP Request Checking: Sends HTTP requests to domains and checks for specified successful status codes.
- Browser Automation: Uses
chromedpto perform browser-based checks, handling JavaScript-rendered content. - Redirection Handling: Detects and logs domain redirections.
- Customizable Parameters: Allows setting of successful status codes, timeout durations, and concurrency levels.
- Detailed Logging: Outputs active and inactive domains to separate files for easy analysis.
Installation
Prerequisites
- Go: Version 1.16 or later. Download Go
- Chromium or Google Chrome: Required for browser automation with
chromedp.
Steps
-
Clone the Repository
git clone https://github.com/murat-exp/Domain-Checker-Tool.git cd domain-checker -
Initialize Go Modules
go mod init domain_checker -
Install Dependencies
go get -u github.com/chromedp/chromedp@latest -
Install Chromium or Chrome
For Debian/Ubuntu:
sudo apt update sudo apt install chromium
Usage
go run domain_checker.go [domain_list_file] [status_codes]
domain_list_file: Path to the file containing the list of domains (one per line).status_codes(Optional): Comma-separated HTTP status codes considered successful (default:200).
Examples
-
Default status code
200:go run domain_checker.go domains.txt -
Custom status codes
200,301,302:go run domain_checker.go domains.txt 200,301,302
Example Output
Console Output
Active: http://example.com (Status Code: 200)
Active: https://test.com (Status Code: 200) (Redirected to: newdomain.com)
Generated Files
active_domains.txt: List of active domains with optional redirection info.inactive_domains.txt: List of inactive or unreachable domains.
Configuration
Customize the tool by modifying variables in domain_checker.go:
-
Successful Status Codes
successStatusCodes = []int{200, 301, 302} -
Timeout Duration
timeout = 10 * time.Second -
Retry Count
retryCount = 2 -
Max Concurrent Checks
maxConcurrentChecks = 100
How It Works
-
Domain Reading: Reads domains from a file, ensuring each is non-empty.
-
DNS Resolution: Checks if each domain is resolvable; unresolvable domains are marked inactive.
-
HTTP Requests:
- Sends GET requests over
http://andhttps://. - Follows redirects up to 10 levels.
- Validates response status codes.
- Sends GET requests over
-
Browser Automation:
- Uses
chromedpfor headless browser checks. - Navigates to the final URL.
- Can be extended to perform content verification.
- Uses
-
Concurrency Control:
- Employs goroutines and a semaphore pattern.
- Limits concurrent checks to prevent resource exhaustion.
-
Logging:
- Active domains are logged to
active_domains.txt. - Inactive domains are logged to
inactive_domains.txt. - Console output provides real-time feedback.
- Active domains are logged to
Dependencies
-
Go Modules: For dependency management.
go mod init domain_checker -
Chromedp: For headless browser automation.
go get -u github.com/chromedp/chromedp@latest -
Chromium or Google Chrome: Required by
chromedp.
Troubleshooting
-
No Output or Errors:
- Ensure Go modules are initialized (
go mod init domain_checker). - Install dependencies (
go get -u github.com/chromedp/chromedp).
- Ensure Go modules are initialized (
-
Chromium Not Found:
-
Install Chromium or Chrome:
sudo apt update sudo apt install chromium
-
-
Go Version Issues:
-
Verify Go version:
go version -
Update Go if necessary.
-
-
Permission Errors:
- Run commands without
sudounless necessary. - Check file permissions for
active_domains.txtandinactive_domains.txt.
- Run commands without
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of your changes.
Acknowledgments
Special thanks to:
-
Chromedp: For browser automation capabilities.
-
The Go Community: For providing a robust ecosystem for high-performance applications.
