You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`DNS.Zone.Manager` - CRUD operations and zone lifecycle management
55
+
-`DNS.Zone.Store` - ETS-based persistent zone storage
56
+
-`DNS.Zone.Cache` - TTL-based caching with automatic expiration
57
+
-`DNS.Zone.Loader` - Zone file loading from various sources
58
+
-`DNS.Zone.FileParser` - BIND format zone file parsing
59
+
-`DNS.Zone.Validator` - Zone validation and diagnostics
60
+
-`DNS.Zone.DNSSEC` - DNSSEC signing and validation (basic implementation)
61
+
62
+
### Key Implementation Patterns
63
+
64
+
**Protocol-Based Architecture**
65
+
All DNS entities implement `DNS.Parameter.to_iodata/1` for binary serialization and `String.Chars.to_string/1` for display. This provides consistent behavior across the entire library.
66
+
67
+
**Binary Pattern Matching**
68
+
Heavy use of Elixir's pattern matching on binaries for efficient DNS protocol parsing, particularly in domain name compression and record data parsing.
69
+
70
+
**ETS-Based Storage**
71
+
Zone management uses ETS tables for in-memory storage with separate tables for zone data and metadata, supporting high-concurrency access patterns.
72
+
73
+
**Type System Integration**
74
+
Comprehensive use of `@type` specifications throughout the codebase with proper union types and structured error returns.
75
+
76
+
### Critical Implementation Details
77
+
78
+
**Domain Name Compression**
79
+
Located in `DNS.Message.Domain.parse_domain_from_message/2` - handles DNS message compression with pointer dereferencing. This is a performance-critical path and security-sensitive area.
80
+
81
+
**Record Data Dispatch**
82
+
`DNS.Message.Record.Data` uses pattern matching on record type integers to dispatch to appropriate record type modules. New record types require adding entries in multiple places.
83
+
84
+
**Zone Manager Store Integration**
85
+
`DNS.Zone.Manager` coordinates with `DNS.Zone.Store` for persistence and `DNS.Zone.Cache` for temporary storage, with automatic initialization and cleanup.
86
+
87
+
**Error Handling Patterns**
88
+
The codebase uses a mix of throw/1 for parsing errors and {:error, reason} tuples for validation errors. This inconsistency is being addressed in ongoing refactoring.
89
+
90
+
### Security Considerations
91
+
92
+
**Domain Compression Depth**
93
+
Domain name decompression in `DNS.Message.Domain` is vulnerable to compression loop attacks. Implementation must include depth limits.
94
+
95
+
**Binary Data Validation**
96
+
Record length fields (rdlength) require validation to prevent memory exhaustion attacks. Critical in `DNS.Message.Record.from_iodata/2`.
97
+
98
+
**DNSSEC Implementation**
99
+
Current DNSSEC support uses placeholder cryptographic functions. Production use requires proper cryptographic implementations.
100
+
36
101
## Development Commands
37
102
38
103
### Testing
39
104
```bash
40
-
mix test# Run all tests
41
-
mix test test/path/to/file_test.exs # Run specific test file
105
+
mix test# Run all tests
106
+
mix test test/dns/message_test.exs # Run specific test file
107
+
mix test --include wip # Run tests including WIP tagged tests
108
+
mix test --trace # Run tests with detailed output
42
109
```
43
110
44
-
### Code Quality
111
+
### Code Quality & Analysis
45
112
```bash
46
-
mix format # Format code with Elixir formatter
47
-
mix credo # Run static code analysis
48
-
mix dialyzer # Run type checking and static analysis
113
+
mix format # Format code with Elixir formatter
114
+
mix format --check-formatted # Check if code is formatted
115
+
mix credo # Run static code analysis
116
+
mix dialyzer # Run type checking and static analysis
117
+
```
118
+
119
+
### Build & Dependencies
120
+
```bash
121
+
mix deps.get # Install/update dependencies
122
+
mix compile # Compile the project
123
+
mix clean # Clean compiled files
124
+
mix compile --warnings-as-errors # Treat warnings as errors (CI requirement)
49
125
```
50
126
51
127
### Documentation
52
128
```bash
53
-
mix docs # Generate documentation
54
-
mix help# List available tasks
129
+
mix docs # Generate documentation
130
+
mix help# List available tasks
131
+
```
132
+
133
+
### Publishing & Release
134
+
```bash
135
+
mix publish # Format and publish to hex.pm (custom alias)
136
+
mix hex.publish --yes # Direct publish to hex.pm
55
137
```
56
138
57
-
### Publishing
139
+
### Manual Testing Scripts
58
140
```bash
59
-
mix publish # Format and publish to hex.pm
141
+
elixir test_all_string_chars.exs # Test all record type String.Chars implementations
142
+
elixir test_zone_system.exs # Test zone management functionality
60
143
```
61
144
62
145
## Key Patterns
@@ -70,6 +153,8 @@ mix publish # Format and publish to hex.pm
70
153
## File Organization
71
154
72
155
-`lib/dns/` - Core DNS implementation
73
-
-`test/dns/` - Corresponding test files
74
-
-`priv/data/` - DNS root hints and zone data
75
-
-`doc/` - Generated documentation
156
+
-`message/` - DNS protocol message handling
157
+
-`zone/` - Zone management operations
158
+
-`test/dns/` - Comprehensive test suite matching lib structure
159
+
-`priv/data/` - DNS root hints and zone data files
160
+
-`test_*_string_chars.exs` - Manual testing scripts for protocol implementations
0 commit comments