- Fix DNSSEC to properly sign entire RRsets together instead of individual records - Implement proper SOA record serialization according to RFC 1035 - Add primaryNameserver option to IDnsServerOptions for customizable SOA mname field - Add comprehensive tests for DNSSEC RRset signing and SOA record handling - Update documentation with v7.4.3 improvements Co-Authored-By: User <user@example.com>
6.6 KiB
SmartDNS Improvement Plan
Command to reread CLAUDE.md: cat /home/philkunz/.claude/CLAUDE.md
Critical Issue: Support Multiple DNS Records of Same Type
Current Status: ✅ IMPLEMENTED (v7.4.2)
Priority: HIGH - This issue blocks proper DNS server operation and domain registration
All Issues Fixed (v7.4.3)
Successfully Implemented:
- ✅ Multiple DNS Records Support (v7.4.2) - Core fix allowing multiple handlers to contribute records
- ✅ DNSSEC RRset Signing - Now signs entire RRsets together instead of individual records
- ✅ SOA Record Serialization - Proper SOA record encoding for DNSSEC compatibility
- ✅ Configurable Primary Nameserver - Added
primaryNameserver
option to IDnsServerOptions
Problem Summary
The DNS server currently exits after finding the first matching handler for a query, preventing it from serving multiple records of the same type (e.g., multiple NS records, multiple A records for round-robin, multiple TXT records).
Implementation Plan
Phase 1: Analysis and Testing ✅ COMPLETED
- Create comprehensive test cases demonstrating the issue
- Test with multiple NS records scenario
- Test with multiple A records (round-robin) scenario
- Test with multiple TXT records scenario
- Document current behavior vs expected behavior
Phase 2: Core Fix Implementation ✅ COMPLETED
- Remove the
break
statement inprocessDnsRequest
method (line 609) - Ensure all matching handlers are processed
- Accumulate all answers from matching handlers
- Add NS record serialization for DNSSEC support
Phase 3: Handler Interface Enhancement (Optional)
- Consider allowing handlers to return arrays of records
- Update
IDnsHandler
interface to supportDnsAnswer | DnsAnswer[] | null
- Update processing logic to handle array responses
- Maintain backward compatibility with existing handlers
Phase 4: Testing and Validation
- Test multiple NS records return correctly
- Test round-robin DNS with multiple A records
- Test multiple TXT records (SPF + DKIM + verification)
- Test DNSSEC signatures for multiple records
- Verify no regression in single-record scenarios
Phase 5: Documentation and Examples
- Update documentation with multiple record examples
- Add example for registering multiple NS records
- Add example for round-robin DNS setup
- Document best practices for handler registration
Technical Details
Current Code Issue (ts_server/classes.dnsserver.ts:609)
answered = true;
break; // <-- This prevents multiple handlers from contributing answers
Proposed Fix
answered = true;
// Continue processing other handlers instead of breaking
Success Criteria
- DNS queries return ALL matching records from ALL matching handlers
- Domain registration with multiple NS records succeeds
- Round-robin DNS works with multiple A records
- Multiple TXT records can be served for the same domain
- DNSSEC signatures are properly generated for all returned records
Implementation Summary
What Was Fixed
- Core Issue Resolved: Removed the
break
statement at line 609 inprocessDnsRequest
that was preventing multiple handlers from contributing DNS answers - NS Record Serialization: Added NS record type support in
serializeRData
method for DNSSEC compatibility - Result: DNS server now correctly returns multiple records of the same type from different handlers
Test Results
- ✅ Multiple NS records now work (2+ nameservers returned)
- ✅ Round-robin DNS with multiple A records works
- ✅ Multiple TXT records (SPF, DKIM, verification) work
- ⚠️ DNSSEC RRSIG generation needs additional fixes for multiple record scenarios
Code Changes
// Before (line 609):
answered = true;
break; // This was preventing multiple handlers from running
// After:
answered = true;
// Continue processing other handlers to allow multiple records
Next Steps and Future Improvements
Released in v7.4.2
The critical issue of supporting multiple DNS records of the same type has been successfully implemented and released in version 7.4.2.
Comprehensive Fix Plan for Remaining Issues
Command to reread CLAUDE.md: cat /home/philkunz/.claude/CLAUDE.md
Outstanding Issues to Address
1. DNSSEC RRSIG Generation for Multiple Records
Status: Pending
Priority: Medium
Issue: When multiple records of the same type are returned with DNSSEC enabled, the RRSIG generation may encounter issues with the current implementation. Each record gets its own RRSIG instead of signing the entire RRset together.
Implementation Plan:
- Modify
processDnsRequest
to collect all records of the same type before signing - Create a map to group answers by record type
- After all handlers have been processed, sign each RRset as a whole
- Generate one RRSIG per record type (not per record)
- Update tests to verify proper DNSSEC RRset signing
- Ensure canonical ordering of records in RRset for consistent signatures
Code Changes:
- Refactor the DNSSEC signing logic in
processDnsRequest
- Move RRSIG generation outside the handler loop
- Group records by type before signing
2. SOA Record Timeout Issues
Status: Not Started
Priority: Low
Issue: SOA queries sometimes timeout or return incorrect data, possibly related to incomplete SOA record serialization.
Implementation Plan:
- Implement proper SOA record serialization in
serializeRData
method - Ensure all SOA fields are properly encoded in wire format
- Add comprehensive SOA record tests
- Verify SOA responses with standard DNS tools (dig, nslookup)
Code Changes:
- Implement SOA serialization in
serializeRData
method - Add SOA-specific test cases
3. Configurable DNSSEC Zone Prefix
Status: Not Started
Priority: Low
Issue: The server hardcodes 'ns1.' prefix for SOA mname field which may not match actual nameserver names.
Implementation Plan:
- Add
primaryNameserver
option toIDnsServerOptions
- Default to
ns1.{dnssecZone}
if not provided - Update SOA record generation to use configurable nameserver
- Update documentation with new option
- Add tests for custom primary nameserver configuration
Code Changes:
- Add
primaryNameserver?: string
toIDnsServerOptions
- Update SOA mname field generation logic
- Update constructor to handle the new option
Testing Recommendations
- Test DNSSEC validation with multiple records using
dig +dnssec
- Verify SOA records with
dig SOA
- Test custom nameserver configuration
- Validate with real-world DNS resolvers (Google DNS, Cloudflare)