public void MessageBytesTest() { var message = new DnsMessage(); message.Header = new DnsHeader() { ID = 1234, QR = 0, QDCOUNT = 1, ANCOUNT = 1, }; message.Question = new DnsQuestion() { QClass = 1, QType = 1, Name = "f00.test", }; message.Answer.Add(new ARecord("f00.test", "127.0.0.2") { RClass = 1, Ttl = 10, }); Console.WriteLine(message.ToMultiString()); Console.WriteLine($"Header is {message.Header.ToBytes().Length} bytes."); Console.WriteLine($"Question is {message.Question.ToBytes().Length} bytes."); var messageBytes = DnsUtils.DnsMessageToBytes(message); Console.WriteLine($"Message is {messageBytes.Length} bytes"); var message2 = DnsUtils.ReadDnsMessage(messageBytes); Console.WriteLine(message2.ToMultiString()); }
public void Response2Test() { byte[] messageBytes = File.ReadAllBytes(Path.Combine("Files", "dns-02-response.dat")); var message = DnsUtils.ReadDnsMessage(messageBytes); Console.WriteLine(message.ToMultiString()); }