[PR #1874] [MERGED] authority: parse with default record class IN. #2668

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

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/1874
Author: @cpu
Created: 1/8/2023
Status: Merged
Merged: 1/17/2023
Merged by: @bluejekyll

Base: mainHead: cpu-zone-parse-default-class


📝 Commits (3)

  • e6133fe authority: parse with default record class IN.
  • 736d0b6 client: unit test default zone class.
  • 2db6212 tests: add file authority test for default IN.

📊 Changes

4 files changed (+64 additions, -1 deletions)

View changed files

📝 crates/client/src/serialize/txt/zone.rs (+33 -0)
📝 crates/server/src/store/file/authority.rs (+2 -1)
📝 crates/server/tests/store_file_tests.rs (+16 -0)
tests/test-data/test_configs/default/implicitclass.zone (+13 -0)

📄 Description

Description

Prior to this branch parsing a zone file with trust-dns that did not specify a record class on one or more records would panic with an error with the message "record class not specified":

min.toml
directory = "/home/daniel/Code/Rust/trust-dns-experiments/zones"

[[zones]]
zone = "example.com"
zone_type = "Primary"
file = "example.com.zone"
zones/example.com
example.com.  	3600	SOA	ns1.example.com. contact.example.com. 2022100601 3600 900 1209600 86400
trust-dns -c ./min.toml
$> trust-dns -c ./min.toml
1673213115:INFO:trust_dns:335:Trust-DNS 0.22.0 starting
1673213115:INFO:trust_dns:340:loading configuration from: "./min.toml"
1673213115:INFO:trust_dns_server::store::file::authority:189:loading zone file: "/home/daniel/Code/Rust/trust-dns-experiments/zones/example.com.zone"
thread 'main' panicked at 'could not load zone example.com.: failed to parse example.com.zone: Error { kind: Message("record class not specified") }', bin/src/named.rs:366:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

On the topic of whether class is optional or not, RFC1035 5.1 says:

The RR begins with optional TTL and class fields, followed by a type and RDATA field appropriate to the type and class. Class and type use the standard mnemonics, TTL is a decimal integer. Omitted class and TTL values are default to the last explicitly stated values.

Unfortunately this is somewhat ambiguous for the case where no explicit class value has been stated. It appears other software like BIND, knot, and bwesterb/go-zonefile will all assume a class of IN and parse the zone successfully but I can't find chapter and verse in the RFC to justify this.

Change

Assuming the internet class and parsing the zone seems like sensible behaviour, so this branch updates the try_from_config function's call to parse such that it defaults to the IN class when not specified, matching the behaviour of other software.

Anecdotally I've carried my zone files through ~3 generations of different authoritative DNS servers and this is the first time one has balked. :-) While I can fix my own zones to specify the class I thought it might help others to support an implicit class natively.

I've added a couple small unit tests in 736d0b6 and 2db6212. They're in separate commits to make iteration easier (I'm generally new to working in Rust on larger codebases).


🔄 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/1874 **Author:** [@cpu](https://github.com/cpu) **Created:** 1/8/2023 **Status:** ✅ Merged **Merged:** 1/17/2023 **Merged by:** [@bluejekyll](https://github.com/bluejekyll) **Base:** `main` ← **Head:** `cpu-zone-parse-default-class` --- ### 📝 Commits (3) - [`e6133fe`](https://github.com/hickory-dns/hickory-dns/commit/e6133fe58905687acff0acf9478e19ddee043906) authority: parse with default record class IN. - [`736d0b6`](https://github.com/hickory-dns/hickory-dns/commit/736d0b6c9f2fe00655452a98c0edaede612d5743) client: unit test default zone class. - [`2db6212`](https://github.com/hickory-dns/hickory-dns/commit/2db621243917d92644a88bd0dd08c8e3c558fb68) tests: add file authority test for default IN. ### 📊 Changes **4 files changed** (+64 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/client/src/serialize/txt/zone.rs` (+33 -0) 📝 `crates/server/src/store/file/authority.rs` (+2 -1) 📝 `crates/server/tests/store_file_tests.rs` (+16 -0) ➕ `tests/test-data/test_configs/default/implicitclass.zone` (+13 -0) </details> ### 📄 Description #### Description Prior to this branch parsing a zone file with `trust-dns` that did not specify a record class on one or more records would panic with an error with the message "record class not specified": <details> <summary>min.toml</summary> ```toml directory = "/home/daniel/Code/Rust/trust-dns-experiments/zones" [[zones]] zone = "example.com" zone_type = "Primary" file = "example.com.zone" ``` </details> <details> <summary>zones/example.com</summary> ``` example.com. 3600 SOA ns1.example.com. contact.example.com. 2022100601 3600 900 1209600 86400 ``` </details> <details> <summary>trust-dns -c ./min.toml</summary> ```bash $> trust-dns -c ./min.toml 1673213115:INFO:trust_dns:335:Trust-DNS 0.22.0 starting 1673213115:INFO:trust_dns:340:loading configuration from: "./min.toml" 1673213115:INFO:trust_dns_server::store::file::authority:189:loading zone file: "/home/daniel/Code/Rust/trust-dns-experiments/zones/example.com.zone" thread 'main' panicked at 'could not load zone example.com.: failed to parse example.com.zone: Error { kind: Message("record class not specified") }', bin/src/named.rs:366:27 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` </summary> </details> On the topic of whether class is optional or not, [RFC1035 5.1](https://datatracker.ietf.org/doc/html/rfc1035#section-5.1) says: > The RR begins with optional TTL and class fields, followed by a type and RDATA field appropriate to the type and class. Class and type use the standard mnemonics, TTL is a decimal integer. Omitted class and TTL values are default to the last explicitly stated values. Unfortunately this is somewhat ambiguous for the case where no explicit class value has been stated. It appears other software like BIND, knot, and bwesterb/go-zonefile will all assume a class of IN and parse the zone successfully but I can't find chapter and verse in the RFC to justify this. #### Change Assuming the internet class and parsing the zone seems like sensible behaviour, so this branch updates the `try_from_config` function's call to `parse` such that it defaults to the IN class when not specified, matching the behaviour of other software. Anecdotally I've carried my zone files through ~3 generations of different authoritative DNS servers and this is the first time one has balked. :-) While I can fix my own zones to specify the class I thought it might help others to support an implicit class natively. I've added a couple small unit tests in [736d0b6](https://github.com/bluejekyll/trust-dns/pull/1874/commits/736d0b6c9f2fe00655452a98c0edaede612d5743) and 2db6212. They're in separate commits to make iteration easier (_I'm generally new to working in Rust on larger codebases_). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:01:40 +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#2668
No description provided.