@push.rocks/smartdns 7.0.2 → 7.4.0
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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts_server/classes.dnsserver.d.ts +45 -0
- package/dist_ts_server/classes.dnsserver.js +201 -41
- package/dist_ts_server/plugins.d.ts +2 -1
- package/dist_ts_server/plugins.js +3 -2
- package/package.json +2 -2
- package/readme.hints.md +97 -1
- package/readme.md +618 -197
- package/readme.plan.md +103 -0
- package/ts/00_commitinfo_data.ts +1 -1
package/readme.plan.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# DNS Server Interface Binding Implementation Plan
|
|
2
|
+
|
|
3
|
+
Command to reread CLAUDE.md: `cat /home/philkunz/.claude/CLAUDE.md`
|
|
4
|
+
|
|
5
|
+
## Overview ✅ COMPLETED
|
|
6
|
+
Enable specific interface binding for the DNSServer class to allow binding to specific network interfaces instead of all interfaces (0.0.0.0).
|
|
7
|
+
|
|
8
|
+
## Implementation Status: COMPLETED ✅
|
|
9
|
+
|
|
10
|
+
### What was implemented:
|
|
11
|
+
|
|
12
|
+
✅ **1. Updated IDnsServerOptions Interface**
|
|
13
|
+
- Added optional `udpBindInterface?: string` property (defaults to '0.0.0.0')
|
|
14
|
+
- Added optional `httpsBindInterface?: string` property (defaults to '0.0.0.0')
|
|
15
|
+
- Located in `ts_server/classes.dnsserver.ts:5-11`
|
|
16
|
+
|
|
17
|
+
✅ **2. Modified DnsServer.start() Method**
|
|
18
|
+
- Updated UDP server binding to use `this.options.udpBindInterface || '0.0.0.0'`
|
|
19
|
+
- Updated HTTPS server listening to use `this.options.httpsBindInterface || '0.0.0.0'`
|
|
20
|
+
- Added IP address validation before binding
|
|
21
|
+
- Updated console logging to show specific interface being bound
|
|
22
|
+
- Located in `ts_server/classes.dnsserver.ts:699-752`
|
|
23
|
+
|
|
24
|
+
✅ **3. Added IP Address Validation**
|
|
25
|
+
- Created `isValidIpAddress()` method supporting IPv4 and IPv6
|
|
26
|
+
- Validates interface addresses before binding
|
|
27
|
+
- Throws meaningful error messages for invalid addresses
|
|
28
|
+
- Located in `ts_server/classes.dnsserver.ts:392-398`
|
|
29
|
+
|
|
30
|
+
✅ **4. Updated Documentation**
|
|
31
|
+
- Added dedicated "Interface Binding" section to readme.md
|
|
32
|
+
- Included examples for localhost-only binding (`127.0.0.1`, `::1`)
|
|
33
|
+
- Documented security considerations and use cases
|
|
34
|
+
- Added examples for specific interface binding
|
|
35
|
+
|
|
36
|
+
✅ **5. Added Comprehensive Tests**
|
|
37
|
+
- **localhost binding test**: Verifies binding to `127.0.0.1` instead of `0.0.0.0`
|
|
38
|
+
- **Invalid IP validation test**: Ensures invalid IP addresses are rejected
|
|
39
|
+
- **IPv6 support test**: Tests `::1` binding (with graceful fallback if IPv6 unavailable)
|
|
40
|
+
- **Backwards compatibility**: Existing tests continue to work with default behavior
|
|
41
|
+
- Located in `test/test.server.ts`
|
|
42
|
+
|
|
43
|
+
✅ **6. Updated restartHttpsServer Method**
|
|
44
|
+
- Modified to respect interface binding options during certificate updates
|
|
45
|
+
- Ensures Let's Encrypt certificate renewal maintains interface binding
|
|
46
|
+
|
|
47
|
+
## ✅ Implementation Results
|
|
48
|
+
|
|
49
|
+
### Test Results
|
|
50
|
+
All interface binding functionality has been successfully tested:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
✅ should bind to localhost interface only (318ms)
|
|
54
|
+
- UDP DNS server running on 127.0.0.1:8085
|
|
55
|
+
- HTTPS DNS server running on 127.0.0.1:8084
|
|
56
|
+
|
|
57
|
+
✅ should reject invalid IP addresses (151ms)
|
|
58
|
+
- Validates IP address format correctly
|
|
59
|
+
- Throws meaningful error messages
|
|
60
|
+
|
|
61
|
+
✅ should work with IPv6 localhost if available
|
|
62
|
+
- Gracefully handles IPv6 unavailability in containerized environments
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Benefits Achieved
|
|
66
|
+
- ✅ Enhanced security by allowing localhost-only binding
|
|
67
|
+
- ✅ Support for multi-homed servers with specific interface requirements
|
|
68
|
+
- ✅ Better isolation in containerized environments
|
|
69
|
+
- ✅ Backwards compatible (defaults to current behavior)
|
|
70
|
+
- ✅ IP address validation with clear error messages
|
|
71
|
+
- ✅ IPv4 and IPv6 support
|
|
72
|
+
|
|
73
|
+
## Example Usage (Now Available)
|
|
74
|
+
```typescript
|
|
75
|
+
// Bind to localhost only
|
|
76
|
+
const dnsServer = new DnsServer({
|
|
77
|
+
httpsKey: cert.key,
|
|
78
|
+
httpsCert: cert.cert,
|
|
79
|
+
httpsPort: 443,
|
|
80
|
+
udpPort: 53,
|
|
81
|
+
dnssecZone: 'example.com',
|
|
82
|
+
udpBindInterface: '127.0.0.1',
|
|
83
|
+
httpsBindInterface: '127.0.0.1'
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Bind to specific interface
|
|
87
|
+
const dnsServer = new DnsServer({
|
|
88
|
+
// ... other options
|
|
89
|
+
udpBindInterface: '192.168.1.100',
|
|
90
|
+
httpsBindInterface: '192.168.1.100'
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Files to Modify
|
|
95
|
+
1. `ts_server/classes.dnsserver.ts` - Interface and implementation
|
|
96
|
+
2. `readme.md` - Documentation updates
|
|
97
|
+
3. `test/test.server.ts` - Add interface binding tests
|
|
98
|
+
|
|
99
|
+
## Testing Strategy
|
|
100
|
+
- Unit tests for interface validation
|
|
101
|
+
- Integration tests for binding behavior
|
|
102
|
+
- Error handling tests for invalid interfaces
|
|
103
|
+
- Backwards compatibility tests
|
package/ts/00_commitinfo_data.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartdns',
|
|
6
|
-
version: '7.0
|
|
6
|
+
version: '7.4.0',
|
|
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
|
}
|