Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
56a33dd7ae | |||
9e5fae055f | |||
afdd6a6074 | |||
3d06131e04 | |||
1811ebd4d4 |
22
changelog.md
22
changelog.md
@ -1,5 +1,27 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-06-01 - 7.5.0 - feat(dnssec)
|
||||
Add MX record DNSSEC support for proper serialization and authentication of mail exchange records
|
||||
|
||||
- Serialize MX records by combining a 16-bit preference with the exchange domain name
|
||||
- Enable DNSSEC signature generation for MX records to authenticate mail exchange data
|
||||
- Update documentation to include the new MX record DNSSEC support in version v7.4.8
|
||||
|
||||
## 2025-05-30 - 7.4.7 - fix(dnsserver)
|
||||
Update documentation to clarify the primaryNameserver option and SOA record behavior in the DNS server. The changes detail how the primaryNameserver configuration customizes the SOA mname, ensures proper DNSSEC signing for RRsets, and updates the configuration interface examples.
|
||||
|
||||
- Documented the primaryNameserver option in IDnsServerOptions with default behavior (ns1.{dnssecZone})
|
||||
- Clarified SOA record generation including mname, rname, serial, and TTL fields
|
||||
- Updated readme examples to demonstrate binding interfaces and proper DNS server configuration
|
||||
|
||||
## 2025-05-30 - 7.4.6 - docs(readme)
|
||||
Document the primaryNameserver option and SOA record behavior in the DNS server documentation.
|
||||
|
||||
- Added comprehensive documentation for the primaryNameserver option in IDnsServerOptions
|
||||
- Explained SOA record automatic generation and the role of the primary nameserver
|
||||
- Clarified that only one nameserver is designated as primary in SOA records
|
||||
- Updated the configuration options interface documentation with all available options
|
||||
|
||||
## 2025-05-30 - 7.4.3 - fix(dnsserver)
|
||||
Fix DNSSEC RRset signing, SOA record timeout issues, and add configurable primary nameserver support.
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@push.rocks/smartdns",
|
||||
"version": "7.4.5",
|
||||
"version": "7.5.0",
|
||||
"private": false,
|
||||
"description": "A robust TypeScript library providing advanced DNS management and resolution capabilities including support for DNSSEC, custom DNS servers, and integration with various DNS providers.",
|
||||
"exports": {
|
||||
|
@ -110,6 +110,13 @@ The test suite demonstrates:
|
||||
2. **SOA Record Serialization**: Implemented proper SOA record encoding for DNSSEC compatibility
|
||||
3. **Configurable Primary Nameserver**: Added `primaryNameserver` option to customize SOA mname field
|
||||
|
||||
## Recent Improvements (v7.4.8)
|
||||
|
||||
1. **MX Record DNSSEC Support**: Implemented MX record serialization for DNSSEC signing
|
||||
- MX records consist of a 16-bit preference value followed by the exchange domain name
|
||||
- Properly serializes both components for DNSSEC signature generation
|
||||
- Enables mail exchange records to be authenticated with DNSSEC
|
||||
|
||||
## Known Limitations
|
||||
|
||||
1. **Handler Deduplication**: If the same handler is registered multiple times, it will contribute duplicate records (this may be desired behavior for some use cases)
|
41
readme.md
41
readme.md
@ -198,7 +198,8 @@ const secureServer = new DnsServer({
|
||||
httpsCert: 'path/to/cert.pem',
|
||||
dnssecZone: 'example.com',
|
||||
udpBindInterface: '127.0.0.1', // Bind UDP to localhost only
|
||||
httpsBindInterface: '127.0.0.1' // Bind HTTPS to localhost only
|
||||
httpsBindInterface: '127.0.0.1', // Bind HTTPS to localhost only
|
||||
primaryNameserver: 'ns1.example.com' // Optional: primary nameserver for SOA records (defaults to ns1.{dnssecZone})
|
||||
});
|
||||
|
||||
// Register a handler for all subdomains of example.com
|
||||
@ -224,6 +225,35 @@ await dnsServer.start();
|
||||
console.log('DNS Server started!');
|
||||
```
|
||||
|
||||
### SOA Records and Primary Nameserver
|
||||
|
||||
The DNS server automatically generates SOA (Start of Authority) records for zones when no specific handler matches a query. The SOA record contains important zone metadata including the primary nameserver.
|
||||
|
||||
```typescript
|
||||
const dnsServer = new DnsServer({
|
||||
udpPort: 53,
|
||||
httpsPort: 443,
|
||||
httpsKey: 'path/to/key.pem',
|
||||
httpsCert: 'path/to/cert.pem',
|
||||
dnssecZone: 'example.com',
|
||||
primaryNameserver: 'ns1.example.com' // Specify your actual primary nameserver
|
||||
});
|
||||
|
||||
// Without primaryNameserver, the SOA mname defaults to 'ns1.{dnssecZone}'
|
||||
// In this case, it would be 'ns1.example.com'
|
||||
|
||||
// The automatic SOA record includes:
|
||||
// - mname: Primary nameserver (from primaryNameserver option)
|
||||
// - rname: Responsible person email (hostmaster.{dnssecZone})
|
||||
// - serial: Unix timestamp
|
||||
// - refresh: 3600 (1 hour)
|
||||
// - retry: 600 (10 minutes)
|
||||
// - expire: 604800 (7 days)
|
||||
// - minimum: 86400 (1 day)
|
||||
```
|
||||
|
||||
**Important**: Even if you have multiple nameservers (NS records), only one is designated as the primary in the SOA record. All authoritative nameservers should return the same SOA record.
|
||||
|
||||
### DNSSEC Support
|
||||
|
||||
The DNS server includes comprehensive DNSSEC support with automatic key generation and record signing:
|
||||
@ -314,9 +344,16 @@ The DNS server supports manual socket handling for advanced use cases like clust
|
||||
|
||||
```typescript
|
||||
export interface IDnsServerOptions {
|
||||
// ... standard options ...
|
||||
httpsKey: string; // Path or content of HTTPS private key
|
||||
httpsCert: string; // Path or content of HTTPS certificate
|
||||
httpsPort: number; // Port for DNS-over-HTTPS
|
||||
udpPort: number; // Port for standard UDP DNS
|
||||
dnssecZone: string; // Zone name for DNSSEC signing
|
||||
udpBindInterface?: string; // IP address to bind UDP socket (default: '0.0.0.0')
|
||||
httpsBindInterface?: string; // IP address to bind HTTPS server (default: '0.0.0.0')
|
||||
manualUdpMode?: boolean; // Handle UDP sockets manually
|
||||
manualHttpsMode?: boolean; // Handle HTTPS sockets manually
|
||||
primaryNameserver?: string; // Primary nameserver for SOA records (default: 'ns1.{dnssecZone}')
|
||||
}
|
||||
```
|
||||
|
||||
|
165
readme.plan.md
165
readme.plan.md
@ -1,165 +0,0 @@
|
||||
# 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:
|
||||
1. ✅ **Multiple DNS Records Support** (v7.4.2) - Core fix allowing multiple handlers to contribute records
|
||||
2. ✅ **DNSSEC RRset Signing** - Now signs entire RRsets together instead of individual records
|
||||
3. ✅ **SOA Record Serialization** - Proper SOA record encoding for DNSSEC compatibility
|
||||
4. ✅ **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
|
||||
- [x] Create comprehensive test cases demonstrating the issue
|
||||
- [x] Test with multiple NS records scenario
|
||||
- [x] Test with multiple A records (round-robin) scenario
|
||||
- [x] Test with multiple TXT records scenario
|
||||
- [x] Document current behavior vs expected behavior
|
||||
|
||||
#### Phase 2: Core Fix Implementation ✅ COMPLETED
|
||||
- [x] Remove the `break` statement in `processDnsRequest` method (line 609)
|
||||
- [x] Ensure all matching handlers are processed
|
||||
- [x] Accumulate all answers from matching handlers
|
||||
- [x] 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 support `DnsAnswer | 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)
|
||||
```typescript
|
||||
answered = true;
|
||||
break; // <-- This prevents multiple handlers from contributing answers
|
||||
```
|
||||
|
||||
#### Proposed Fix
|
||||
```typescript
|
||||
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
|
||||
1. **Core Issue Resolved**: Removed the `break` statement at line 609 in `processDnsRequest` that was preventing multiple handlers from contributing DNS answers
|
||||
2. **NS Record Serialization**: Added NS record type support in `serializeRData` method for DNSSEC compatibility
|
||||
3. **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
|
||||
```typescript
|
||||
// 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**:
|
||||
1. Modify `processDnsRequest` to collect all records of the same type before signing
|
||||
2. Create a map to group answers by record type
|
||||
3. After all handlers have been processed, sign each RRset as a whole
|
||||
4. Generate one RRSIG per record type (not per record)
|
||||
5. Update tests to verify proper DNSSEC RRset signing
|
||||
6. 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**:
|
||||
1. Implement proper SOA record serialization in `serializeRData` method
|
||||
2. Ensure all SOA fields are properly encoded in wire format
|
||||
3. Add comprehensive SOA record tests
|
||||
4. 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**:
|
||||
1. Add `primaryNameserver` option to `IDnsServerOptions`
|
||||
2. Default to `ns1.{dnssecZone}` if not provided
|
||||
3. Update SOA record generation to use configurable nameserver
|
||||
4. Update documentation with new option
|
||||
5. Add tests for custom primary nameserver configuration
|
||||
|
||||
**Code Changes**:
|
||||
- Add `primaryNameserver?: string` to `IDnsServerOptions`
|
||||
- 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)
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartdns',
|
||||
version: '7.4.2',
|
||||
version: '7.5.0',
|
||||
description: 'A robust TypeScript library providing advanced DNS management and resolution capabilities including support for DNSSEC, custom DNS servers, and integration with various DNS providers.'
|
||||
}
|
||||
|
@ -809,6 +809,12 @@ export class DnsServer {
|
||||
minimum.writeUInt32BE(data.minimum, 0);
|
||||
|
||||
return Buffer.concat([mname, rname, serial, refresh, retry, expire, minimum]);
|
||||
case 'MX':
|
||||
// MX records contain preference (16-bit) and exchange (domain name)
|
||||
const preference = Buffer.alloc(2);
|
||||
preference.writeUInt16BE(data.preference, 0);
|
||||
const exchange = this.nameToBuffer(data.exchange);
|
||||
return Buffer.concat([preference, exchange]);
|
||||
// Add cases for other record types as needed
|
||||
default:
|
||||
throw new Error(`Serialization for record type ${type} is not implemented.`);
|
||||
|
Loading…
x
Reference in New Issue
Block a user