MailGuard-RS
π‘οΈ A fast temporary email and malicious domain detection library using SURBL DNS queries
Features
- β‘ Fast Detection: Quick temporary email detection via SURBL DNS queries
- π Threat Classification: Identify different threat types (spam, phishing, malware, etc.) based on DNS responses
- π Async Support: Tokio-based asynchronous DNS queries
- πΎ Smart Caching: Built-in cache mechanism to avoid duplicate queries
- π¦ Batch Processing: Support for batch detection of multiple emails or domains
- π― Type Safety: Full Rust type system support
How It Works
This library detects temporary emails and malicious domains by querying DNS A records for domain.tempmail.so.multi.surbl.org. If the query returns an IP address in the 127.0.0.x range, it indicates the domain is blacklisted.
Threat Type Classification
Threat types are determined by the last octet of the returned IP address:
| Last Octet | Threat Type | Severity | Description |
|---|---|---|---|
| 2, 9 | Spam | 2 | Spam source |
| 3 | Phishing | 4 | Phishing website |
| 4, 6, 7, 11 | Malware | 5 | Malware |
| 5 | Botnet | 4 | Botnet |
| 10 | PUP | 1 | Potentially Unwanted Program |
Quick Start
Add the following to your Cargo.toml:
[]
= "0.1.0"
= { = "1.0", = ["full"] }
Features
This library supports optional features:
cache- Enable LRU caching functionality (disabled by default)
To enable caching:
[]
= { = "0.1.0", = ["cache"] }
= { = "1.0", = ["full"] }
Basic Usage
use check_email;
async
Advanced Usage
use ;
use Duration;
async
Domain-Only Detection
use check_domain;
async
API Documentation
Structs
EmailStatus
DomainStatus
ThreatType
Main Functions
check_email(email: &str) -> Result<EmailStatus, MailGuardError>check_domain(domain: &str) -> Result<DomainStatus, MailGuardError>check_emails_batch(emails: &[&str]) -> Vec<Result<EmailStatus, MailGuardError>>
Running Examples
# Clone the repository
# Run the main example
# Run simple example
# Run advanced example
# Run tests
Performance Characteristics
- DNS Queries: Default timeout of 5 seconds
- Caching: Default TTL of 5 minutes
- Memory Usage: Low memory footprint with LRU cache strategy
- Concurrency: Supports high-concurrency async queries
Error Handling
use ;
match check_email.await
Configuration
MailGuardConfig
Dependencies
tokio- Async runtimetrust-dns-resolver- DNS queriesregex- Email validationthiserror- Error handlingserde- Serialization supportlru- Cache implementationtracing- Structured logging support
License
Apache-2.0 License
Contributing
Issues and Pull Requests are welcome!
Related Projects
- SURBL - URI DNS Blacklist Service
Changelog
See CHANGELOG.md for detailed version history.
Support
If you find this project helpful, please consider giving it a β on GitHub!