helia-dnslink
DNSLink resolution for Helia - enables domain names to point to IPFS content using DNS TXT records.
Features
- ✅ DNS-over-HTTPS resolution using Google DNS
- ✅ Full DNSLink specification support
- ✅ Handles
_dnslink.subdomain per spec - ✅ Supports multiple namespaces:
/ipfs/,/ipns/,/dnslink/ - ✅ Recursive DNSLink resolution (up to 32 levels)
- ✅ CNAME following for delegated domains
- ✅ Path extraction from DNSLink values
- ✅ Configurable DNS caching
- ✅ TypeScript Helia API-compatible
Installation
Add to your Cargo.toml:
[]
= "0.1.2"
Usage
Basic Example
use ;
async
With Options
use ;
async
Custom Configuration
use ;
let dnslink = dns_link?;
DNSLink Format
DNSLink uses DNS TXT records to point domains to IPFS content:
_dnslink.example.com. 60 IN TXT "dnslink=/ipfs/bafybei..."
Supported formats:
dnslink=/ipfs/<cid>- Points to IPFS contentdnslink=/ipfs/<cid>/path/to/file- With path componentdnslink=/ipns/<peer-id>- Points to IPNS namednslink=/dnslink/other.com- Recursive DNSLink
Result Types
Error Handling
How It Works
- Query DNS: Queries
_dnslink.{domain}TXT records - Fallback: Falls back to bare domain if
_dnslink.fails - Parse Record: Extracts
dnslink=/namespace/valueformat - Handle Namespace:
/ipfs/<cid>→ Parse CID and return/ipns/<peer-id>→ Parse peer ID and return/dnslink/<domain>→ Recursively resolve
- CNAME: Follows CNAME records if no TXT found
- Recursion: Supports up to 32 levels of recursion
Real-World Examples
Successfully resolves:
ipfs.tech→bafybeibb7bijpaz4kp5qrde45ui66lrzeqdb6kjabyorafmfzc6v6cls7qdocs.ipfs.tech→bafybeihc3gzbj642jgt4dkgxebvnzoww53oahwvfbpxbmiiotajrpx6uja
Testing
Run tests:
Run network tests:
Performance
- DNS resolution: ~0.4-0.8 seconds (with DNS-over-HTTPS)
- Caching: Configurable DNS cache for repeated queries
- Async: Non-blocking async/await operations
Compatibility
- ✅ DNSLink Spec: Fully compliant with DNSLink specification
- ✅ TypeScript Helia: API-compatible factory function pattern
- ✅ IPFS Ecosystem: Works with standard IPFS infrastructure
- ✅ DNS-over-HTTPS: Secure DNS resolution
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.