[PR #2979] [MERGED] Separate encoder's handling of case and compression #3468

Closed
opened 2026-03-16 11:45:15 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/2979
Author: @divergentdave
Created: 5/7/2025
Status: Merged
Merged: 5/13/2025
Merged by: @divergentdave

Base: mainHead: david/encoder-flags


📝 Commits (10+)

  • 71813bd Remove no-op BinEncoder method
  • 3e49834 Remove unused method
  • abe2199 Replace canonical_names flag w/ name encoding enum
  • f7b699d Add setter and getter for name encoding mode
  • 2e8e68e Add canonical form flag, set when encoding TBS
  • 5bc9625 Use name encoding mode directly
  • e1a5ed5 Add ModalEncoder
  • 061d707 Add method to switch name encoding mode for RDATA
  • 60b205b Set RDATA name encoding mode based on record type
  • 351f5c0 Update signature-related encoder uses

📊 Changes

23 files changed (+313 additions, -281 deletions)

View changed files

📝 crates/proto/src/dnssec/nsec3.rs (+4 -3)
📝 crates/proto/src/dnssec/rdata/dnskey.rs (+2 -2)
📝 crates/proto/src/dnssec/rdata/mod.rs (+11 -15)
📝 crates/proto/src/dnssec/rdata/nsec.rs (+6 -5)
📝 crates/proto/src/dnssec/rdata/sig.rs (+9 -8)
📝 crates/proto/src/dnssec/rdata/tsig.rs (+23 -18)
📝 crates/proto/src/dnssec/tbs.rs (+12 -3)
📝 crates/proto/src/op/header.rs (+0 -2)
📝 crates/proto/src/rr/domain/name.rs (+64 -87)
📝 crates/proto/src/rr/lower_name.rs (+1 -13)
📝 crates/proto/src/rr/rdata/caa.rs (+1 -0)
📝 crates/proto/src/rr/rdata/cert.rs (+2 -1)
📝 crates/proto/src/rr/rdata/mx.rs (+3 -4)
📝 crates/proto/src/rr/rdata/name.rs (+8 -60)
📝 crates/proto/src/rr/rdata/naptr.rs (+5 -3)
📝 crates/proto/src/rr/rdata/opt.rs (+5 -2)
📝 crates/proto/src/rr/rdata/soa.rs (+4 -7)
📝 crates/proto/src/rr/rdata/srv.rs (+3 -6)
📝 crates/proto/src/rr/rdata/svcb.rs (+7 -5)
📝 crates/proto/src/rr/record_data.rs (+8 -10)

...and 3 more files

📄 Description

This reimplements name handling modes in the encoder. The existing canonical names flag is replaced with three different flags, that indicate whether canonical form is being used, whether names should be encoded in compressed form, and whether names should be transformed to lowercase before encoding. The canonical form flag is used to communicate from the ultimate caller to the RData enums, and indicate whether the normal rules or canonical form rules should be used. There, the other two flags are temporarily set before encoding the RDATA, and affect the behavior of Name::emit(). There are three different combinations of behavior for names within RDATA, depending on the record type. I cleaned up some other uses of flags and specialized emit methods elsewhere, to centralize canonical form handling in the RData enums. Note that some record types do not require changing encoder flags at all, because they do not contain any domain names in their RDATA.

Closes #2934.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/2979 **Author:** [@divergentdave](https://github.com/divergentdave) **Created:** 5/7/2025 **Status:** ✅ Merged **Merged:** 5/13/2025 **Merged by:** [@divergentdave](https://github.com/divergentdave) **Base:** `main` ← **Head:** `david/encoder-flags` --- ### 📝 Commits (10+) - [`71813bd`](https://github.com/hickory-dns/hickory-dns/commit/71813bdc209883c7f34c0c41781a02adf84691e5) Remove no-op BinEncoder method - [`3e49834`](https://github.com/hickory-dns/hickory-dns/commit/3e49834f4bb8fb88f32c80dc348f540c2cb34aef) Remove unused method - [`abe2199`](https://github.com/hickory-dns/hickory-dns/commit/abe2199050f06155fb564e30c33782c076653d30) Replace canonical_names flag w/ name encoding enum - [`f7b699d`](https://github.com/hickory-dns/hickory-dns/commit/f7b699dadfe695ddc83c649e19cf6e9e3aa7703c) Add setter and getter for name encoding mode - [`2e8e68e`](https://github.com/hickory-dns/hickory-dns/commit/2e8e68ecce2240e89c0c7aa303b454d84e635dc1) Add canonical form flag, set when encoding TBS - [`5bc9625`](https://github.com/hickory-dns/hickory-dns/commit/5bc962530f07e246defe59c97fe3d274f2ca7f64) Use name encoding mode directly - [`e1a5ed5`](https://github.com/hickory-dns/hickory-dns/commit/e1a5ed5145c5f751b2321cecdc1e3ef332de423a) Add ModalEncoder - [`061d707`](https://github.com/hickory-dns/hickory-dns/commit/061d707b48c57f1eba237540c6a33b5ca7ba6e7a) Add method to switch name encoding mode for RDATA - [`60b205b`](https://github.com/hickory-dns/hickory-dns/commit/60b205b44dd2f4adec346a98525474cd90975410) Set RDATA name encoding mode based on record type - [`351f5c0`](https://github.com/hickory-dns/hickory-dns/commit/351f5c0ae92157ccd736d9e9b46f7528d95d5ac7) Update signature-related encoder uses ### 📊 Changes **23 files changed** (+313 additions, -281 deletions) <details> <summary>View changed files</summary> 📝 `crates/proto/src/dnssec/nsec3.rs` (+4 -3) 📝 `crates/proto/src/dnssec/rdata/dnskey.rs` (+2 -2) 📝 `crates/proto/src/dnssec/rdata/mod.rs` (+11 -15) 📝 `crates/proto/src/dnssec/rdata/nsec.rs` (+6 -5) 📝 `crates/proto/src/dnssec/rdata/sig.rs` (+9 -8) 📝 `crates/proto/src/dnssec/rdata/tsig.rs` (+23 -18) 📝 `crates/proto/src/dnssec/tbs.rs` (+12 -3) 📝 `crates/proto/src/op/header.rs` (+0 -2) 📝 `crates/proto/src/rr/domain/name.rs` (+64 -87) 📝 `crates/proto/src/rr/lower_name.rs` (+1 -13) 📝 `crates/proto/src/rr/rdata/caa.rs` (+1 -0) 📝 `crates/proto/src/rr/rdata/cert.rs` (+2 -1) 📝 `crates/proto/src/rr/rdata/mx.rs` (+3 -4) 📝 `crates/proto/src/rr/rdata/name.rs` (+8 -60) 📝 `crates/proto/src/rr/rdata/naptr.rs` (+5 -3) 📝 `crates/proto/src/rr/rdata/opt.rs` (+5 -2) 📝 `crates/proto/src/rr/rdata/soa.rs` (+4 -7) 📝 `crates/proto/src/rr/rdata/srv.rs` (+3 -6) 📝 `crates/proto/src/rr/rdata/svcb.rs` (+7 -5) 📝 `crates/proto/src/rr/record_data.rs` (+8 -10) _...and 3 more files_ </details> ### 📄 Description This reimplements name handling modes in the encoder. The existing canonical names flag is replaced with three different flags, that indicate whether canonical form is being used, whether names should be encoded in compressed form, and whether names should be transformed to lowercase before encoding. The canonical form flag is used to communicate from the ultimate caller to the RData enums, and indicate whether the normal rules or canonical form rules should be used. There, the other two flags are temporarily set before encoding the RDATA, and affect the behavior of `Name::emit()`. There are three different combinations of behavior for names within RDATA, depending on the record type. I cleaned up some other uses of flags and specialized emit methods elsewhere, to centralize canonical form handling in the RData enums. Note that some record types do not require changing encoder flags at all, because they do not contain any domain names in their RDATA. Closes #2934. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:45:15 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#3468
No description provided.