@push.rocks/smartdns 7.4.6 → 7.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartdns',
6
- version: '7.4.2',
6
+ version: '7.4.7',
7
7
  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.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxzQkFBc0I7SUFDNUIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHlMQUF5TDtDQUN2TSxDQUFBIn0=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@push.rocks/smartdns",
3
- "version": "7.4.6",
3
+ "version": "7.4.7",
4
4
  "private": false,
5
5
  "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.",
6
6
  "exports": {
package/readme.md CHANGED
@@ -198,7 +198,8 @@ const secureServer = new DnsServer({
198
198
  httpsCert: 'path/to/cert.pem',
199
199
  dnssecZone: 'example.com',
200
200
  udpBindInterface: '127.0.0.1', // Bind UDP to localhost only
201
- httpsBindInterface: '127.0.0.1' // Bind HTTPS to localhost only
201
+ httpsBindInterface: '127.0.0.1', // Bind HTTPS to localhost only
202
+ primaryNameserver: 'ns1.example.com' // Optional: primary nameserver for SOA records (defaults to ns1.{dnssecZone})
202
203
  });
203
204
 
204
205
  // Register a handler for all subdomains of example.com
@@ -224,6 +225,35 @@ await dnsServer.start();
224
225
  console.log('DNS Server started!');
225
226
  ```
226
227
 
228
+ ### SOA Records and Primary Nameserver
229
+
230
+ 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.
231
+
232
+ ```typescript
233
+ const dnsServer = new DnsServer({
234
+ udpPort: 53,
235
+ httpsPort: 443,
236
+ httpsKey: 'path/to/key.pem',
237
+ httpsCert: 'path/to/cert.pem',
238
+ dnssecZone: 'example.com',
239
+ primaryNameserver: 'ns1.example.com' // Specify your actual primary nameserver
240
+ });
241
+
242
+ // Without primaryNameserver, the SOA mname defaults to 'ns1.{dnssecZone}'
243
+ // In this case, it would be 'ns1.example.com'
244
+
245
+ // The automatic SOA record includes:
246
+ // - mname: Primary nameserver (from primaryNameserver option)
247
+ // - rname: Responsible person email (hostmaster.{dnssecZone})
248
+ // - serial: Unix timestamp
249
+ // - refresh: 3600 (1 hour)
250
+ // - retry: 600 (10 minutes)
251
+ // - expire: 604800 (7 days)
252
+ // - minimum: 86400 (1 day)
253
+ ```
254
+
255
+ **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.
256
+
227
257
  ### DNSSEC Support
228
258
 
229
259
  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
314
344
 
315
345
  ```typescript
316
346
  export interface IDnsServerOptions {
317
- // ... standard options ...
318
- manualUdpMode?: boolean; // Handle UDP sockets manually
319
- manualHttpsMode?: boolean; // Handle HTTPS sockets manually
347
+ httpsKey: string; // Path or content of HTTPS private key
348
+ httpsCert: string; // Path or content of HTTPS certificate
349
+ httpsPort: number; // Port for DNS-over-HTTPS
350
+ udpPort: number; // Port for standard UDP DNS
351
+ dnssecZone: string; // Zone name for DNSSEC signing
352
+ udpBindInterface?: string; // IP address to bind UDP socket (default: '0.0.0.0')
353
+ httpsBindInterface?: string; // IP address to bind HTTPS server (default: '0.0.0.0')
354
+ manualUdpMode?: boolean; // Handle UDP sockets manually
355
+ manualHttpsMode?: boolean; // Handle HTTPS sockets manually
356
+ primaryNameserver?: string; // Primary nameserver for SOA records (default: 'ns1.{dnssecZone}')
320
357
  }
321
358
  ```
322
359
 
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@push.rocks/smartdns',
6
- version: '7.4.2',
6
+ version: '7.4.7',
7
7
  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.'
8
8
  }
package/readme.plan.md DELETED
@@ -1,165 +0,0 @@
1
- # SmartDNS Improvement Plan
2
-
3
- Command to reread CLAUDE.md: `cat /home/philkunz/.claude/CLAUDE.md`
4
-
5
- ## Critical Issue: Support Multiple DNS Records of Same Type
6
-
7
- ### Current Status: ✅ IMPLEMENTED (v7.4.2)
8
- **Priority: HIGH** - This issue blocks proper DNS server operation and domain registration
9
-
10
- ## All Issues Fixed (v7.4.3)
11
-
12
- ### Successfully Implemented:
13
- 1. ✅ **Multiple DNS Records Support** (v7.4.2) - Core fix allowing multiple handlers to contribute records
14
- 2. ✅ **DNSSEC RRset Signing** - Now signs entire RRsets together instead of individual records
15
- 3. ✅ **SOA Record Serialization** - Proper SOA record encoding for DNSSEC compatibility
16
- 4. ✅ **Configurable Primary Nameserver** - Added `primaryNameserver` option to IDnsServerOptions
17
-
18
- ### Problem Summary
19
- 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).
20
-
21
- ### Implementation Plan
22
-
23
- #### Phase 1: Analysis and Testing ✅ COMPLETED
24
- - [x] Create comprehensive test cases demonstrating the issue
25
- - [x] Test with multiple NS records scenario
26
- - [x] Test with multiple A records (round-robin) scenario
27
- - [x] Test with multiple TXT records scenario
28
- - [x] Document current behavior vs expected behavior
29
-
30
- #### Phase 2: Core Fix Implementation ✅ COMPLETED
31
- - [x] Remove the `break` statement in `processDnsRequest` method (line 609)
32
- - [x] Ensure all matching handlers are processed
33
- - [x] Accumulate all answers from matching handlers
34
- - [x] Add NS record serialization for DNSSEC support
35
-
36
- #### Phase 3: Handler Interface Enhancement (Optional)
37
- - [ ] Consider allowing handlers to return arrays of records
38
- - [ ] Update `IDnsHandler` interface to support `DnsAnswer | DnsAnswer[] | null`
39
- - [ ] Update processing logic to handle array responses
40
- - [ ] Maintain backward compatibility with existing handlers
41
-
42
- #### Phase 4: Testing and Validation
43
- - [ ] Test multiple NS records return correctly
44
- - [ ] Test round-robin DNS with multiple A records
45
- - [ ] Test multiple TXT records (SPF + DKIM + verification)
46
- - [ ] Test DNSSEC signatures for multiple records
47
- - [ ] Verify no regression in single-record scenarios
48
-
49
- #### Phase 5: Documentation and Examples
50
- - [ ] Update documentation with multiple record examples
51
- - [ ] Add example for registering multiple NS records
52
- - [ ] Add example for round-robin DNS setup
53
- - [ ] Document best practices for handler registration
54
-
55
- ### Technical Details
56
-
57
- #### Current Code Issue (ts_server/classes.dnsserver.ts:609)
58
- ```typescript
59
- answered = true;
60
- break; // <-- This prevents multiple handlers from contributing answers
61
- ```
62
-
63
- #### Proposed Fix
64
- ```typescript
65
- answered = true;
66
- // Continue processing other handlers instead of breaking
67
- ```
68
-
69
- ### Success Criteria
70
- - DNS queries return ALL matching records from ALL matching handlers
71
- - Domain registration with multiple NS records succeeds
72
- - Round-robin DNS works with multiple A records
73
- - Multiple TXT records can be served for the same domain
74
- - DNSSEC signatures are properly generated for all returned records
75
-
76
- ### Implementation Summary
77
-
78
- #### What Was Fixed
79
- 1. **Core Issue Resolved**: Removed the `break` statement at line 609 in `processDnsRequest` that was preventing multiple handlers from contributing DNS answers
80
- 2. **NS Record Serialization**: Added NS record type support in `serializeRData` method for DNSSEC compatibility
81
- 3. **Result**: DNS server now correctly returns multiple records of the same type from different handlers
82
-
83
- #### Test Results
84
- - ✅ Multiple NS records now work (2+ nameservers returned)
85
- - ✅ Round-robin DNS with multiple A records works
86
- - ✅ Multiple TXT records (SPF, DKIM, verification) work
87
- - ⚠️ DNSSEC RRSIG generation needs additional fixes for multiple record scenarios
88
-
89
- #### Code Changes
90
- ```typescript
91
- // Before (line 609):
92
- answered = true;
93
- break; // This was preventing multiple handlers from running
94
-
95
- // After:
96
- answered = true;
97
- // Continue processing other handlers to allow multiple records
98
- ```
99
-
100
- ## Next Steps and Future Improvements
101
-
102
- ### Released in v7.4.2
103
- The critical issue of supporting multiple DNS records of the same type has been successfully implemented and released in version 7.4.2.
104
-
105
- ## Comprehensive Fix Plan for Remaining Issues
106
-
107
- Command to reread CLAUDE.md: `cat /home/philkunz/.claude/CLAUDE.md`
108
-
109
- ### Outstanding Issues to Address
110
-
111
- #### 1. DNSSEC RRSIG Generation for Multiple Records
112
- **Status**: Pending
113
- **Priority**: Medium
114
- **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.
115
-
116
- **Implementation Plan**:
117
- 1. Modify `processDnsRequest` to collect all records of the same type before signing
118
- 2. Create a map to group answers by record type
119
- 3. After all handlers have been processed, sign each RRset as a whole
120
- 4. Generate one RRSIG per record type (not per record)
121
- 5. Update tests to verify proper DNSSEC RRset signing
122
- 6. Ensure canonical ordering of records in RRset for consistent signatures
123
-
124
- **Code Changes**:
125
- - Refactor the DNSSEC signing logic in `processDnsRequest`
126
- - Move RRSIG generation outside the handler loop
127
- - Group records by type before signing
128
-
129
- #### 2. SOA Record Timeout Issues
130
- **Status**: Not Started
131
- **Priority**: Low
132
- **Issue**: SOA queries sometimes timeout or return incorrect data, possibly related to incomplete SOA record serialization.
133
-
134
- **Implementation Plan**:
135
- 1. Implement proper SOA record serialization in `serializeRData` method
136
- 2. Ensure all SOA fields are properly encoded in wire format
137
- 3. Add comprehensive SOA record tests
138
- 4. Verify SOA responses with standard DNS tools (dig, nslookup)
139
-
140
- **Code Changes**:
141
- - Implement SOA serialization in `serializeRData` method
142
- - Add SOA-specific test cases
143
-
144
- #### 3. Configurable DNSSEC Zone Prefix
145
- **Status**: Not Started
146
- **Priority**: Low
147
- **Issue**: The server hardcodes 'ns1.' prefix for SOA mname field which may not match actual nameserver names.
148
-
149
- **Implementation Plan**:
150
- 1. Add `primaryNameserver` option to `IDnsServerOptions`
151
- 2. Default to `ns1.{dnssecZone}` if not provided
152
- 3. Update SOA record generation to use configurable nameserver
153
- 4. Update documentation with new option
154
- 5. Add tests for custom primary nameserver configuration
155
-
156
- **Code Changes**:
157
- - Add `primaryNameserver?: string` to `IDnsServerOptions`
158
- - Update SOA mname field generation logic
159
- - Update constructor to handle the new option
160
-
161
- ### Testing Recommendations
162
- - Test DNSSEC validation with multiple records using `dig +dnssec`
163
- - Verify SOA records with `dig SOA`
164
- - Test custom nameserver configuration
165
- - Validate with real-world DNS resolvers (Google DNS, Cloudflare)