[GH-ISSUE #1155] feature request: make trust_dns_proto Message::update_counts public #617

Open
opened 2026-03-15 23:28:44 +03:00 by kerem · 2 comments
Owner

Originally created by @Sherlock-Holo on GitHub (Jun 28, 2020).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1155

Is your feature request related to a problem? Please describe.
I am trying to use trust_dns_proto to write a dns server, instead of using DnsRequest, I am using the Message directly but it can't use set_query_count because Message only implements Deref and can return the &Header. If Message can return a &mut Header or implement DerefMut this problem can be fixed.

Describe the solution you'd like
Message can return a &mut Header or implement DerefMut

Describe alternatives you've considered
No good idea, only can use message.queries().len() to get the query count

Originally created by @Sherlock-Holo on GitHub (Jun 28, 2020). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1155 **Is your feature request related to a problem? Please describe.** I am trying to use trust_dns_proto to write a dns server, instead of using `DnsRequest`, I am using the `Message` directly but it can't use `set_query_count` because `Message` only implements `Deref` and can return the `&Header`. If `Message` can return a `&mut Header` or implement `DerefMut` this problem can be fixed. **Describe the solution you'd like** `Message` can return a `&mut Header` or implement `DerefMut` **Describe alternatives you've considered** No good idea, only can use `message.queries().len()` to get the query count
Author
Owner
<!-- gh-comment-id:651296126 --> @fluxxu commented on GitHub (Jun 29, 2020): This field will be updated automatically before the `Message` been encoded to its binary form: https://github.com/bluejekyll/trust-dns/blob/main/crates/proto/src/op/message.rs#L88 https://github.com/bluejekyll/trust-dns/blob/main/crates/proto/src/op/message.rs#L793 https://github.com/bluejekyll/trust-dns/blob/main/crates/proto/src/op/message.rs#L799
Author
Owner

@bluejekyll commented on GitHub (Jun 29, 2020):

Exactly. I'd be a little concerned about exposing that as that the logic in this path since it is not obvious. We serialize the Message, and leave space in the buffer to go back and fill in the header. This is because of the way that we handle things like signing the message for SIG0.

<!-- gh-comment-id:651318942 --> @bluejekyll commented on GitHub (Jun 29, 2020): Exactly. I'd be a little concerned about exposing that as that the logic in this path since it is not obvious. We serialize the Message, and leave space in the buffer to go back and fill in the header. This is because of the way that we handle things like signing the message for SIG0.
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#617
No description provided.