using System; using System.Text; namespace DnsClient.Protocol { /* https://tools.ietf.org/html/rfc1035#section-3.3.10: 3.3.10. NULL RDATA format (EXPERIMENTAL) +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ / / / / +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ Anything at all may be in the RDATA field so long as it is 65535 octets or less. */ /// /// Experimental RR, not sure if the implementation is actually correct either (not tested). /// /// RFC 1035 public class NullRecord : DnsResourceRecord { /// /// Gets any data stored in this record. /// /// /// The byte array. /// public byte[] Anything { get; } /// /// Gets the raw data of this record as UTF8 string. /// public string AsString { get; } /// /// Initializes a new instance of the class. /// /// The information. /// Anything. /// If or is null. public NullRecord(ResourceRecordInfo info, byte[] anything) : base(info) { Anything = anything ?? throw new ArgumentNullException(nameof(anything)); try { AsString = Encoding.UTF8.GetString(anything); } catch { // ignore errors. } } private protected override string RecordToString() { return $"\\# {Anything.Length} {AsString}"; } } }