A high-performance web service that checks if a target domain is included (directly or indirectly) in another domain's SPF (Sender Policy Framework) record chain.
- 🚀 Fast asynchronous DNS lookups
- 🔄 Recursive checking of SPF include chains
- 📋 Returns complete SPF record and include chain information
- 💓 Health check endpoint
- 🔒 Secure and efficient with Rust
- 🌐 Easy to use HTML UI
Checks if a target domain is included in another domain's SPF record chain.
GET /api/v1/check-spf?domain={domain}&target={target}domain: The domain to check the SPF record for (e.g.,example.com)target: The domain to look for in the SPF include chain (e.g.,_spf.example.com)
{
"found": true,
"checked_domains": 3,
"domain": "example.com",
"target": "spf.protection.outlook.com",
"elapsed_ms": 42,
"has_spf_record": true,
"spf_record": "v=spf1 include:spf.protection.outlook.com -all",
"included_domains": ["spf.protection.outlook.com"],
"fallback_check": false
}found: Boolean indicating if the target was found in the SPF chainchecked_domains: Number of domains checked in the processdomain: The domain that was checked, normalized (lowercase, without surrounding whitespace or trailing dot)target: The domain that was searched for, normalized the same wayelapsed_ms: Time taken for the check in millisecondshas_spf_record: Boolean indicating if the domain has an SPF recordspf_record: The complete SPF record of the main domain (if exists, otherwisenull)included_domains: List of domains included in the main SPF record (if exists, otherwisenull)fallback_check:trueif the target was not included by name, so the IP networks (ip4/ip6) of both SPF chains were compared to determinefound;falseif the target was found by name
{
"error": "DNS_LOOKUP_FAILED"
}Common error codes:
INVALID_DOMAIN(400 Bad Request):domainortargetis emptyDNS_LOOKUP_FAILED: Unable to perform DNS lookup orTXTrecord does not existSPF_PARSE_FAILED: Invalid SPF record formatMULTIPLE_SPF_RECORDS: The domain publishes more than one SPF record, which receivers treat as apermerror(RFC 7208, section 4.5)
GET /healthReturns 200 OK if the service is running.
http://localhost:8080/uiReturns a simple HTML UI for checking SPF records.
Check if outlook.com's SPF is included in example.com's SPF chain:
curl "http://localhost:8080/api/v1/check-spf?domain=example.com&target=spf.protection.outlook.com"And an example that should actually come back positive, check if the SPF chain of easybill.de includes _spf.easybill.de:
curl "http://localhost:8080/api/v1/check-spf?domain=easybill.de&target=_spf.easybill.de"- Ensure you have Rust installed
- Clone the repository
- Build and run:
cargo build --release
./target/release/spf-checkThe service will listen on 0.0.0.0:8080 by default.
| Environment variable | Default | Description |
|---|---|---|
PORT |
8080 |
Port to listen on. The service always binds to 0.0.0.0. |
PORT=3000 ./target/release/spf-checkEs bietet sich an, direkt coverage zu erstellen. Dafür cargo install cargo-llvm-cov, und dann cargo llvm-cov --workspace --open --output-dir=coverage.
- Asynchronous processing allows handling multiple requests simultaneously
- Each request maintains its own state, preventing cross-request interference
- Efficient DNS caching through the trust-dns-resolver
- axum: Web framework
- tokio: Async runtime
- trust-dns-resolver: DNS resolution
- decon-spf: SPF record parsing
- serde: Serialization/Deserialization
- chrono: Timestamp formatting