Check URLs that filtered (or not) in Iran.
Project description
Check Filtering
A command-line tool to check if domains are filtered (blocked) in Iran by analyzing DNS responses.
🔍 How It Works
This tool checks if a domain is blocked by Iranian ISPs by:
- Resolving the domain's A record using DNS
- Comparing the resolved IP addresses against known blocking IPs used by Iranian ISPs
- Reporting whether the domain is blocked or accessible
Note: This tool can only detect DNS-based blocking and does not have the power to detect other types of filtering or network disorders.
✨ Features
- 🚀 Fast async DNS resolution - Check multiple domains concurrently
- 📋 Multiple input methods - Single domain, comma-separated list, or file
- 🎨 Beautiful CLI output - Rich formatted tables with live updates
- 🔧 Configurable - Custom DNS servers and timeout settings
📋 Requirements
- Python 3.10+
📦 Installation
From PyPI
pip install check-filter
From Source
git clone https://github.com/hatamiarash7/CheckFiltering.git
cd CheckFiltering
poetry install
You can also download the wheel package from the release page.
🚀 Usage
Command Line Interface
Check a Single Domain
check-filter domain github.com
Check Multiple Domains
check-filter domains github.com,google.com,twitter.com
Check Domains from File
Create a file with domain names (one per line). Lines starting with # are treated as comments:
# Social media
github.com
twitter.com
facebook.com
# Development
gitlab.com
stackoverflow.com
Then run:
check-filter file domains.txt
Show Version
check-filter --version
# or
check-filter -v
Show Help
check-filter --help
check-filter domain --help
check-filter domains --help
check-filter file --help
As a Python Library
import asyncio
from check_filter import DomainChecker, FilterStatus
async def main():
checker = DomainChecker()
# Check a single domain
result = await checker.acheck("google.com")
print(f"{result.domain}: {result.status.value}")
print(f"Blocked: {result.is_blocked}")
print(f"IPs: {result.ips}")
# Check multiple domains concurrently
results = await checker.acheck_many([
"google.com",
"twitter.com",
"github.com",
])
for result in results:
status = "🚫 Blocked" if result.is_blocked else "✅ Free"
print(f"{result.domain}: {status}")
asyncio.run(main())
Custom Configuration
from check_filter import DomainChecker
# Use custom blocked IPs and DNS servers
checker = DomainChecker(
blocked_ips={"10.10.34.34", "10.10.34.35"},
nameservers=["8.8.8.8", "8.8.4.4"],
timeout=10.0,
)
Using CheckResult
from check_filter import CheckResult, FilterStatus
# CheckResult is a dataclass with useful properties
result = await checker.acheck("example.com")
# Access properties
print(result.domain) # "example.com"
print(result.status) # FilterStatus.FREE
print(result.is_free) # True
print(result.is_blocked) # False
print(result.ips) # frozenset({'93.184.216.34'})
print(result.error) # None (or error message if failed)
# Backward compatible tuple unpacking
domain, is_free = result
🛠️ Development
Setup Development Environment
# Clone the repository
git clone https://github.com/hatamiarash7/CheckFiltering.git
cd CheckFiltering
# Install dependencies with dev tools
make install-dev
Available Commands
make help # Show all available commands
make test # Run tests
make test-cov # Run tests with coverage report
make lint # Run all linters
make lint-fix # Run linters with auto-fix
make format # Format code with black and isort
make type-check # Run type checking with mypy
make check # Run all checks (format, lint, type-check, test)
make build # Build package
make clean # Clean build artifacts
Running Tests
# Run all tests
make test
# Run tests with coverage
make test-cov
# Run fast tests (exclude slow/integration tests)
make test-fast
📄 API Reference
DomainChecker
Main class for checking domain filtering status.
DomainChecker(
blocked_ips: Set[str] | None = None, # Custom blocked IPs
nameservers: list[str] | None = None, # DNS servers to use
timeout: float = 5.0, # DNS query timeout
)
Methods:
acheck(domain: str) -> CheckResult- Check a single domainacheck_many(domains: list[str]) -> list[CheckResult]- Check multiple domains
CheckResult
Dataclass containing the result of a domain check.
Attributes:
domain: str- The checked domainstatus: FilterStatus- The filtering statusips: frozenset[str]- Resolved IP addresseserror: str | None- Error message if check failed
Properties:
is_blocked: bool- True if domain is blockedis_free: bool- True if domain is not blocked
FilterStatus
Enum with possible filtering statuses:
FREE- Domain is accessibleBLOCKED- Domain is blockedERROR- Check failed (timeout, etc.)UNKNOWN- Domain doesn't exist (NXDOMAIN)
💛 Support
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch:
git checkout -b feature/my-new-feature - Install development dependencies:
make install-dev - Make your changes and add tests
- Run checks:
make check - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin feature/my-new-feature - Submit a pull request
🐛 Issues
Found a bug or have a suggestion? Please open an issue.
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file check_filter-2.5.0.tar.gz.
File metadata
- Download URL: check_filter-2.5.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.1 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
125afac3a9976b788812e024ef7123e5875d11d38ee68ef820b92b233ca8fcb8
|
|
| MD5 |
947701fc514dd5f630a5cca300d2b082
|
|
| BLAKE2b-256 |
a2802a9d052019340539f30ad63c14beaf1dd9bf5c288dae1e52abb083b61a7b
|
File details
Details for the file check_filter-2.5.0-py3-none-any.whl.
File metadata
- Download URL: check_filter-2.5.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.13.1 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8be7ea63d72ec8ec6e2d5c4fbf5718fe088de59a00fb669e1b784b4d51ba99b8
|
|
| MD5 |
49ed8949b149c0dd9437d32e1342a2d5
|
|
| BLAKE2b-256 |
9012afa494e87467e445154a95f7af7041e888dd759fd177b99b0787abc25e19
|