using System; using System.Collections.Generic; using System.Linq; namespace DnsClient.Protocol { /* * RFC 1464 https://tools.ietf.org/html/rfc1464 https://tools.ietf.org/html/rfc1035#section-3.3: is a single length octet followed by that number of characters. is treated as binary information, and can be up to 256 characters in length (including the length octet). https://tools.ietf.org/html/rfc1035#section-3.3.14: TXT RDATA format +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / TXT-DATA / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ where: TXT-DATA One or more s. TXT RRs are used to hold descriptive text. The semantics of the text depends on the domain where it is found. */ /// /// A represending a text resource. /// /// TXT RRs are used to hold descriptive text. The semantics of the text /// depends on the domain where it is found. /// /// /// RFC 1035 /// RFC 1464 public class TxtRecord : DnsResourceRecord { /// /// Gets the list of TXT values of this resource record in escaped form, valid for root file. /// /// /// See https://tools.ietf.org/html/rfc1035#section-5.1 for escape details. /// public ICollection EscapedText { get; } /// /// Gets the actual UTF8 representation of the text values of this record. /// public ICollection Text { get; } /// /// Initializes a new instance of the class. /// /// The information. /// The values. /// The UTF8 values. /// /// If or or is null. /// public TxtRecord(ResourceRecordInfo info, string[] values, string[] utf8Values) : base(info) { EscapedText = values ?? throw new ArgumentNullException(nameof(values)); Text = utf8Values ?? throw new ArgumentNullException(nameof(utf8Values)); } private protected override string RecordToString() { return string.Join(" ", EscapedText.Select(p => "\"" + p + "\"")).Trim(); } } }