[PR #3450] [MERGED] proto: handle $TTL correctly when parsing zone file #3858

Closed
opened 2026-03-16 12:06:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/3450
Author: @ZnqbuZ
Created: 2/3/2026
Status: Merged
Merged: 2/3/2026
Merged by: @djc

Base: mainHead: main


📝 Commits (1)

📊 Changes

4 files changed (+46 additions, -33 deletions)

View changed files

📝 bin/tests/integration/txt_tests.rs (+9 -5)
📝 crates/proto/src/serialize/txt/zone.rs (+33 -26)
📝 tests/test-data/test_configs/dnssec/example.com.zone (+2 -1)
📝 tests/test-data/test_configs/example.com.zone (+2 -1)

📄 Description

  • The TTL of the last record should only be used when $TTL does not exist.
  • The TTL of records should not be derived from the SOA record’s value after RFC 2308, so this is removed as well. but so many tests depend on it so it's kept

Issue

Consider the following code

use hickory_proto::serialize::txt::Parser;

fn main() {
    let zone = r"
$ORIGIN .
$TTL 3600
a 10 IN TXT
b IN TXT
";

    let (_, records) = Parser::new(zone, None, None).parse().unwrap();
    let records = records.into_iter().map(|(_, r)| r.into_iter()).flatten();
    for record in records {
        println!("{}", record);
    }
}

expected:

a 10 IN TXT
b 3600 IN TXT

however, result:

a 10 IN TXT
b 10 IN TXT

🔄 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/3450 **Author:** [@ZnqbuZ](https://github.com/ZnqbuZ) **Created:** 2/3/2026 **Status:** ✅ Merged **Merged:** 2/3/2026 **Merged by:** [@djc](https://github.com/djc) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`a9b757a`](https://github.com/hickory-dns/hickory-dns/commit/a9b757a19ddc1908a52f216f69ff4c851ba5a632) fix $TTL ### 📊 Changes **4 files changed** (+46 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `bin/tests/integration/txt_tests.rs` (+9 -5) 📝 `crates/proto/src/serialize/txt/zone.rs` (+33 -26) 📝 `tests/test-data/test_configs/dnssec/example.com.zone` (+2 -1) 📝 `tests/test-data/test_configs/example.com.zone` (+2 -1) </details> ### 📄 Description - The TTL of the last record should only be used when $TTL does not exist. - The TTL of records should not be derived from the SOA record’s value after RFC 2308, so this is removed as well. ~but so many tests depend on it so it's kept~ Issue --- Consider the following code ```rust use hickory_proto::serialize::txt::Parser; fn main() { let zone = r" $ORIGIN . $TTL 3600 a 10 IN TXT b IN TXT "; let (_, records) = Parser::new(zone, None, None).parse().unwrap(); let records = records.into_iter().map(|(_, r)| r.into_iter()).flatten(); for record in records { println!("{}", record); } } ``` expected: ``` a 10 IN TXT b 3600 IN TXT ``` however, result: ``` a 10 IN TXT b 10 IN TXT ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 12:06:29 +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#3858
No description provided.