mafintosh / dns-packet

An abstract-encoding compliant module for encoding / decoding DNS packets
MIT License
206 stars 71 forks source link

Decode TXT responses as text #24

Closed silverwind closed 6 years ago

silverwind commented 6 years ago

These are currently encoded as a Buffer, but I think it would be more useful to have them as a text string. If we decode them as text, should ASCII or UTF8 be used? I'd wager the spec only supports ASCII but I see no harm if we do UTF8 as it is a superset of ASCII.

silverwind commented 6 years ago

@mafintosh any opinion?

mafintosh commented 6 years ago

@silverwind we should keep them as buffers. We used to have them as strings but I remember @watson found it there is some case where they can contain binary data in the spec

silverwind commented 6 years ago

You're right. While the original RFC that specs TXT limits it to ASCII, rfc6763 introduces possibly binary data.

The value is opaque binary data. Often the value for a particular attribute will be US-ASCII [RFC20] or UTF-8 [RFC3629] text, but it is legal for a value to be any binary data.