• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dnsimple / dns_erlang / 21432310233

28 Jan 2026 09:18AM UTC coverage: 85.422% (+0.6%) from 84.852%
21432310233

push

github

web-flow
Consolidate domain name operations into `dns_domain` module — much better perf and RFC compliance (#106)

This PR consolidates all domain name processing functions into a new optimized `dns_domain` module,
removing wrapper functions from `dns`, `dns_encode`, and `dns_decode` modules. This improves code
organization, performance, and RFC compliance.

TL;DR: checkout this branch, do `rebar3 ex_doc`, and see documentation for the `dns_domain` module.

---

### Summary

- **Consolidated** all domain name operations into `dns_domain` module
- **Removed** wrapper functions from `dns`, `dns_encode`, and `dns_decode`
- **Renamed** comparison functions for clarity (`compare_dname` → `are_equal`, `compare_labels` → `are_equal_labels`)
- **Enhanced** `join/1` with `join/2` to support FQDN formatting (trailing dot)
- **Improved** error handling consistency (changed `throw/1` to `error/1` in several places)
- **Refactored** tests to use consistent `{Input, Expected}` pattern
- **Enhanced** [RFC1035](https://datatracker.ietf.org/doc/html/rfc1035) and [RFC9267](https://datatracker.ietf.org/doc/html/rfc9267) compliance with accurate wire format size tracking

### Breaking Changes

All domain name utility functions have been moved from `dns` module to `dns_domain`. The following
functions have been **removed**:

- `dns:dname_to_labels/1`
- `dns:labels_to_dname/1`
- `dns:dname_to_lower_labels/1`
- `dns:dname_to_upper/1`
- `dns:dname_to_lower/1`
- `dns:compare_dname/2`
- `dns:compare_labels/2`
- `dns:escape_label/1`
- `dns_encode:encode_dname/1`
- `dns_decode:decode_dname/2`

**New Feature:** `dns_domain:join/2` now supports FQDN formatting:

### Performance Improvements

Benchmarking results show significant performance improvements across all domain name operations:

**`from_wire/2` (decoding):**
- **2.18x faster** for maximum name length (127 single-byte labels)
- **1.99x faster** for long domain names (5-10 labels)
- **1.78x faster** for maximum label length (63 byt... (continued)

256 of 277 new or added lines in 7 files covered. (92.42%)

51 existing lines in 3 files now uncovered.

3252 of 3807 relevant lines covered (85.42%)

10661.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.23
/src/dns_encode.erl


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc