[GH-ISSUE #598] What should be iterated with trust_dns_proto::rr::rdata::txt::TXT.iter()? #540

Closed
opened 2026-03-15 23:01:03 +03:00 by kerem · 2 comments
Owner

Originally created by @kolbma on GitHub (Oct 30, 2018).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/598

I'm wondering what should be iterated with the iter() method?

I've thought of split-up the TXT RR for the xyz=abc key-value-pairs separated by comma or semikolon. But I only get back one iteration with the complete TXT RR.

An iterable over multiple TXT RRs is also not the case, because these would be in multiple DnsResponse.answers()?!

So is there a bug and the key-value-pairs should be iterable or what is iterable?

Originally created by @kolbma on GitHub (Oct 30, 2018). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/598 I'm wondering what should be iterated with the [iter()](https://docs.rs/trust-dns-proto/0.5.0-alpha.5/trust_dns_proto/rr/rdata/txt/struct.TXT.html#method.iter) method? I've thought of split-up the TXT RR for the xyz=abc key-value-pairs separated by comma or semikolon. But I only get back one iteration with the complete TXT RR. An iterable over multiple TXT RRs is also not the case, because these would be in multiple DnsResponse.answers()?! So is there a bug and the key-value-pairs should be iterable or what is iterable?
kerem 2026-03-15 23:01:03 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@bluejekyll commented on GitHub (Oct 30, 2018):

This iter is exposing the underlying TXT format from RFC 1035:

https://tools.ietf.org/html/rfc1035#section-3.3.14

It is specified as a blob of one or more character strings, ie:

TXT RDATA format

    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    /                   TXT-DATA                    /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

where:

TXT-DATA        One or more <character-string>s.

TXT RRs are used to hold descriptive text.  The semantics of the text
depends on the domain where it is found.

In the general case, I expect most people only associate a single character string with the TXT record, but the spec allows for any number of character strings in a single record, eg you'll usually only have an iteration with one element. Character strings in DNS are similar to C style strings, but have a length attribute before they are parsed from the binary stream. There is no implicit breaking across boundaries of = or spaces or any other delimiter as you've noticed in your experiments. It would require a record to be created with the explicit desire of having more than on character string, which many tools may not make easy, thus most people probably only end up with a single character string.

Hopefully this helps!

<!-- gh-comment-id:434467650 --> @bluejekyll commented on GitHub (Oct 30, 2018): This iter is exposing the underlying TXT format from RFC 1035: https://tools.ietf.org/html/rfc1035#section-3.3.14 It is specified as a blob of one or more character strings, ie: ```text TXT RDATA format +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / TXT-DATA / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ where: TXT-DATA One or more <character-string>s. TXT RRs are used to hold descriptive text. The semantics of the text depends on the domain where it is found. ``` In the general case, I expect most people only associate a single character string with the TXT record, but the spec allows for any number of character strings in a single record, eg you'll usually only have an iteration with one element. Character strings in DNS are similar to C style strings, but have a length attribute before they are parsed from the binary stream. There is no implicit breaking across boundaries of `=` or spaces or any other delimiter as you've noticed in your experiments. It would require a record to be created with the explicit desire of having more than on character string, which many tools may not make easy, thus most people probably only end up with a single character string. Hopefully this helps!
Author
Owner

@kolbma commented on GitHub (Oct 31, 2018):

Ah. So many thanks, @bluejekyll . Your explanation is great. Didn't get it that it might be possible to put there multiple C strings in the RR. Maybe my DNS server wouldn't also parse files with "\0" in it. But it makes senses now ;-)

<!-- gh-comment-id:434619582 --> @kolbma commented on GitHub (Oct 31, 2018): Ah. So many thanks, @bluejekyll . Your explanation is great. Didn't get it that it might be possible to put there multiple C strings in the RR. Maybe my DNS server wouldn't also parse files with "\0" in it. But it makes senses now ;-)
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#540
No description provided.